Tradução dos botões

Delphi

06/06/2016

olá pessoal mais uma vez precisando de ajuda:

alguém sabe com um botao e ele pegar o caption de acordo com a linguagem do sistema operacional:

tipo crio um buttom no delphi com o caption='Cancelar' mas se rodar esta aplicação em um sistema operacional em ingles
o caption fica em ingles 'Cancel'.
Cgm2k7 2013

Cgm2k7 2013

Curtidas 0

Melhor post

Cgm2k7 2013

Cgm2k7 2013

08/07/2016

consegui: Está ae se alguém precisar

function GetButtonCaption(const ButtonCaption: Integer): WideString;
var
   hDll: THandle;
   Buffer: WideString;
   BufferLen: Integer;
begin
   Result := '';
   hDll := LoadLibrary('shell32.dll');
   if hDLL <> 0 then
   begin
      SetLength(Buffer, 255);
      BufferLen := LoadStringW(hdll, ButtonCaption, PWideChar(Buffer), Length(Buffer));
      if BufferLen <> 0 then
         Result := Copy(Buffer, 1, BufferLen);
      FreeLibrary(hDll);
   end;
   begin
   hDll := LoadLibrary('user32.dll');
   if hDll <> 0 then
      SetLength(Buffer, 255);
      BufferLen := LoadStringW(hdll, ButtonCaption, PWideChar(Buffer), Length(Buffer));
      if BufferLen <> 0 then
         Result := Copy(Buffer, 1, BufferLen);
      FreeLibrary(hDll);
   end;
end;

// como usar
BitBtn1.Caption := GetButtonCaption(800);
{
800 = ok
801 = Cancelar
802 = Abordar
803 = tentar novamente
804 = Ignorar
805 = Sim
806 = não
e etc...

Para ver mais código abra as dll com o "Resource Hacker"
}
GOSTEI 1

Mais Respostas

Cgm2k7 2013

Cgm2k7 2013

06/06/2016

help-me
GOSTEI 0
Cgm2k7 2013

Cgm2k7 2013

06/06/2016

consgui assim:

const
  CANCEL_CAPTION_BUTTOM = '"Default=&Cancel",'
    + '"0436=&kanselleer",' //Africâner
		+ '"041C=&Anuloj",' //Albanes
    + '"0416=&Cancelar",' //Portugues br
    + '"0407=&Stornieren",' //Germany
    + '"0403=&Cancel·lar",' //Catalan
    + '"040C=&Annuler",' //French
    + '"040B=&Peruuttaa",' //Finnish Filandês
    + '"040A=&Cancelar",' //Spain
    + '"0C0A=&Cancelar",'
    + '"041F=&Iptal"';  // Tukia
  SELECT_CAPTION_BUTTOM = '"Default=&Select",'
    + '"0436=&Kies",' //Africâner
		+ '"041C=&Zgjedh",' //Albanes
    + '"0416=&Selecionar",' //Portugues br
    + '"0407=&Wählen",' //Germany
    + '"0403=&Seleccionar",' //Catalan
    + '"040C=&Sélectionner",' //French
    + '"040B=&Valita",' //Finnish Filandês
    + '"040A=&Seleccionar",' //Spain
    + '"0C0A=&Seleccionar",'
    + '"041F=&Seçmek"';  // Tukia
  YES_CAPTION_BUTTOM = '"Default=&Yes",'
    + '"0436=&Ja",' //Africâner
		+ '"041C=&Po",' //Albanes
    + '"0416=&Sim",' //Portugues br
    + '"0407=&ja",' //Germany
    + '"0403=&si",' //Catalan
    + '"040C=&oui",' //French
    + '"040B=&kyllä",' //Finnish Filandês
    + '"040A=&sí",' //Spain
    + '"0C0A=&sí",'
    + '"041F=&evet"'; // Tukia
  MINIATURES_CAPTION_BUTTOM = '"Default=Miniatures",'
    + '"0436=Miniatures",' //Africâner
		+ '"041C=Miniatures",' //Albanes
    + '"0416=Miniaturas",' //Portugues br
    + '"0407=Miniaturen",' //Germany
    + '"0403=Miniatures",' //Catalan
    + '"040C=Miniatures",' //French
    + '"040B=Miniatures",' //Finnish Filandês
    + '"040A=Miniaturas",' //Spain
    + '"0C0A=Miniaturas",'
    + '"041F=Minyatürler"';  // Tukia
  SIDEbySIDE_CAPTION_BUTTOM = '"Default=Side by side",'
    + '"0436=Langs mekaar",' //Africâner
		+ '"041C=Krahpërkrah",' //Albanes
    + '"0416=Lado a lado",' //Portugues br
    + '"0407=Nebeneinander",' //Germany
    + '"0403=junts",' //Catalan
    + '"040C=Côte à côte",' //French
    + '"040B=Rinnakkain",' //Finnish Filandês
    + '"040A=Lado a lado",' //Spain
    + '"0C0A=Lado a lado",'
    + '"041F=Yan yana"';  // Tukia
  ICONS_CAPTION_BUTTOM = '"Default=Icons",'
    + '"0436=Ikone",' //Africâner
		+ '"041C=Icons",' //Albanes
    + '"0416=Ícones",' //Portugues br
    + '"0407=Symbole",' //Germany
    + '"0403=Icones",' //Catalan
    + '"040C=icônes",' //French
    + '"040B=kuvakkeet",' //Finnish Filandês
    + '"040A=iconos",' //Spain
    + '"0C0A=iconos",'
    + '"041F=Simgeler"'; // Tukia
  LIST_CAPTION_BUTTOM = '"Default=List",'
    + '"0436=Lys",' //Africâner
		+ '"041C=Listë",' //Albanes
    + '"0416=Lista",' //Portugues br
    + '"0407=Liste",' //Germany
    + '"0403=Llista",' //Catalan
    + '"040C=Liste",' //French
    + '"040B=Lista,' //Finnish Filandês
    + '"040A=Lista",' //Spain
    + '"0C0A=Lista",'
    + '"041F=Liste"';  // Tukia
  DETAILS_CAPTION_BUTTOM = '"Default=Details",'
    + '"0436=Besonderhede",' //Africâner
		+ '"041C=Detalet",' //Albanes
    + '"0416=Detalhes",' //Portugues br
    + '"0407=Details",' //Germany
    + '"0403=Detalls",' //Catalan
    + '"040C=Détails",' //French
    + '"040B=Tarkemmat tiedot",' //Finnish Filandês
    + '"040A=Detalles",' //Spain
    + '"0C0A=Detalles",'
    + '"041F=Ayrintilar"'; // Tukia
	NEW_FOLDER_CAPTIONS =	'"Default=Create &New Folder","0006=Ny mappe",'
		+ '"0007=Neuer Ordner","0009=New folder","000C=Nouveau dossier",'
		+ '"0010=Nuova Cartella","0013=Nieuwe map","0015=Nowy folder",'
		+ '"0016=Criar &Nova Pasta","0406=Ny mappe","0407=Neuer Ordner","0409=New folder",'
	 	+ '"040C=Nouveau dossier","0410=Nuova Cartella","0413=Nieuwe map",'
		+ '"0415=Nowy folder","0416=Criar &Nova Pasta","0807=Neuer Ordner",'
		+ '"0809=Create &New folder","080C=Nouveau dossier","0810=Nuova Cartella",'
		+ '"0C07=Neuer Ordner","0C09=New folder","0C0C=Nouveau dossier",'
		+ '"1007=Neuer Ordner","1009=New folder","100C=Nouveau dossier",'
		+ '"1407=Neuer Ordner","1409=New folder","140C=Nouveau dossier",'
		+ '"1809=Create &New folder","180C=Nouveau dossier","1C09=Create &New folder",'
		+ '"2009=Create &New folder","2809=Create &New folder","2C09=Create &New folder",'
    + '"040B=Uusi kansio","040A=Crear &Nueva carpeta","0C0A=Crear &Nueva carpeta"';
	CURRENT_FOLDER_CAPTIONS = '"Default=Current folder:","0006=Valgt mappe:",'
		+ '"0007=Ausgewählter Ordner:","0009=Current folder:","000C=Dossier courant :",'
		+ '"0010=Cartella selezionata:","0013=Huidige map:","0015=Bie¿±cy folder",'
		+ '"0016=Pasta Atual:","0406=Valgt mappe:","0407=Ausgewählter Ordner:",'
		+ '"0409=Current folder:","040C=Dossier courant :","0410=Cartella selezionata:",'
		+ '"0413=Huidige map:","0415=Bie¿±cy folder","0416=Pasta Atual:",'
		+ '"0807=Ausgewählter Ordner:","0809=Current folder:","080C=Dossier courant :",'
		+ '"0810=Cartella selezionata:","0C07=Ausgewählter Ordner:",'
		+ '"0C09=Current folder:","0C0C=Dossier courant :","1007=Ausgewählter Ordner:",'
		+ '"1009=Current folder:","100C=Dossier courant :","1407=Ausgewählter Ordner:",'
		+ '"1409=Current folder:","140C=Dossier courant :","1809=Current folder:",'
		+ '"180C=Dossier courant :","1C09=Current folder:","2009=Current folder:",'
		+ '"2809=Current folder:","2C09=Current folder:","040B=Nykyinen Kansio",'
    + '"040A=Carpeta actual:","0C0A=Carpeta actual:"';

type
 private
  CNewFolder, CActualFolder, CCancel, CSelect, CYes,
    CMiniatures, CSideByside, CIcons, CList, CDetails: TStringList;

function TStringListCreate(CString: TStringList; sButtonC: String):String;
function LocaleText(List : TStringList) : string;
function GetSystemLang: string;
end;

implementation

{$R *.dfm}

function TForm1.LocaleText(List : TStringList) : string;
var
 FLocale : string;
begin
 FLocale := GetSystemLang;

	if List.Count = 0 then
    Result := ''
	else begin
		if List.IndexOfName(FLocale) <> -1 then
      Result := List.Values[FLocale]
		else
    if List.IndexOfName('Default') <> -1 then
      Result := List.Values['Default']
		else
     Result := List.Values[List.Names[0]];
	end;
end;

function TForm1.GetSystemLang: string;
var
	LangID: DWord;
begin
	LangID := GetSystemDefaultLangID;
	Result := IntToHex(LangID, 4);
end;

function TForm1.TStringListCreate(CString: TStringList; sButtonC: String):String;
begin
   CString := TStringList.Create;
   begin
    CString.CommaText := sButtonC;
    try
    Result := LocaleText(CString);
    finally
    FreeAndNil(CString);
    end;
   end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

  Miniaturas2.Caption := TStringListCreate(CMiniatures,MINIATURES_CAPTION_BUTTOM);
  Ladoalado2.Caption := TStringListCreate(CSideByside,SIDEbySIDE_CAPTION_BUTTOM);
  icones2.Caption := TStringListCreate(CIcons,ICONS_CAPTION_BUTTOM);
  Lista2.Caption := TStringListCreate(CList,LIST_CAPTION_BUTTOM);
  detalhes2.Caption := TStringListCreate(CDetails,DETAILS_CAPTION_BUTTOM);


  BitBtn1.Caption := TStringListCreate(CNewFolder,NEW_FOLDER_CAPTIONS);
  BitBtn2.Caption := TStringListCreate(CActualFolder,CURRENT_FOLDER_CAPTIONS);
  BitBtn3.Caption := TStringListCreate(CCancel,CANCEL_CAPTION_BUTTOM);
  BitBtn4.Caption := TStringListCreate(CSelect,SELECT_CAPTION_BUTTOM);
  BitBtn5.Caption := TStringListCreate(CYes,YES_CAPTION_BUTTOM);

end;



download :Downloadhttp://www.mediafire.com/download/7bgsvx7b4w3g3k5/test.rar

alguém sabe um jeito de pegar do próprio sistema operacional sem ter de criar uma const?
GOSTEI 0
POSTAR