[SOLVED] German caption for System-Buttons lazarus / 31-LCL ---------------------------------------------------------------------- Zvoni · 2023-10-13 11:31 I'll bite. Couldn't find anything (searching for i18n, system buttons etc.) How do i get german captions for the System-Buttons in MessageDlg? mbYesToAll et al ---------------------------------------------------------------------- loaded · 2023-10-13 12:56 "C:\lazarus\lcl\lclstrconsts.pas" line 35 After the change, the file must be saved and the project must be recompiled. ---------------------------------------------------------------------- Zvoni · 2023-10-13 13:10 Quote from: loaded on October 13, 2023, 02:56:53 pm"C:\lazarus\lcl\lclstrconsts.pas" line 35 After the change, the file must be saved and the project must be recompiled. Seriously?? Is there any way, to provide a "translation"-File or something instead of "hacking" into the "originals"? I think i read something along those lines (Resource-Strings being compiled to a po-file and so on) Edit: Due to reasons i CANNOT install poedit on my laptop (Company- Laptop) And yes, i did see the Languages-Folder with the po-files, but i have no clue how to "use" that EDIT2: hmm.... found this....will have to wait for Monday https://wiki.freepascal.org/Everything_else_about_translations ---------------------------------------------------------------------- loaded · 2023-10-13 13:53 Quote from: Zvoni on October 13, 2023, 03:10:35 pmSeriously?? Serious; This was the fastest and shortest way since all my applications running on Windows, except Android applications, were in local languages. If there is another method, I would like to learn it. Respects. ---------------------------------------------------------------------- Bart · 2023-10-13 16:50 Quote from: loaded on October 13, 2023, 03:53:52 pmThis was the fastest and shortest way since all my applications running on Windows, except Android applications, were in local languages. If there is another method, I would like to learn it. Respects. Use the translation mechanisms provided with Lazarus. You can automate this, e.g. I have a nlautotranslation unit that I only need to include in my program and all LCL resource strings will be transated (from a resource included in the executable). Bart ---------------------------------------------------------------------- wp · 2023-10-13 20:26 Copy the file lclstrconsts.de.po from your lazarus installation (folder lcl/languages) into you project folder. This file contains the German translations of the resource strings declared in unit lclstrconsts.Add unit translations to the main form of your project and put the following code into the initialization section of the main unit:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  PODir: String; initialization  PODir := Application.Location;  TranslateUnitResourceStrings('lclstrconsts', PODir + 'lclstrconsts.de.po'); end. Alternatively, if you prefer a monolithic application, do this: Again, copy lclstrconsts.de.po into your project folder structure.Open "Project" > "Project Options" > "Resources". Click "Add". Select the copy of lclstrconsts.de.po. This adds the file to the resources of your application as resource type RT_RCDATA.In the initialization section of your main form (which must use "translations" again, and now also LCLType for the RT_RCDATA identifier) you read the po file from the resource, save it to the temp folder and translate it.In the finalization section delete the po file from the temp folder.Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  PODir: String;  stream: TResourceStream; initialization  PODIR := GetTempDir(false);  ForceDirectories(PODir);  stream := TResourceStream.Create(HINSTANCE, 'lclstrconsts.de', RT_RCDATA);  try    stream.SaveToFile(PODir + 'lclstrconsts.de.po');    TranslateUnitResourceStrings('lclstrconsts', PODir + 'lclstrconsts.de.po');  finally    stream.Free;  end; finalization  DeleteFile(PODir + 'lclstrconsts.de.po'); end. ---------------------------------------------------------------------- Bart · 2023-10-13 21:54 If you have the .po file as a resource there is no need to store it temporarily, you can perform the translation from with the resource. An excerpt from one of my convenience units: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i implementation {$R nlautotranslation.res} procedure TranslateUnitFromResource(const AUnitName: string; ALangID: string='');var Stream: TResourceStream;    ResName: string;    POFile: TPOFile;    hNd: THandle;begin  if (ALangID = '') then    LazGetShortLanguageID(ALangID);  ResName := UpperCase(AUnitName+'.'+ALangID);  hNd := FindResource(hInstance,PChar(ResName),RT_RCDATA);  if (hNd <> 0) then  begin    Stream := TResourceStream.Create(hInstance,ResName,RT_RCDATA);    try      POFile := TPOFile.Create(Stream);      try        TranslateUnitResourceStrings(AUnitName,POFile);      finally        POFile.Free;      end;    finally      Stream.Free;    end;  end;end; initialization  TranslateUnitFromResource('lclstrconsts','nl'); The .res file is created with the lazres tool that comes with lazarus: Code: [Select]    ($Lazarus)\tools\lazres nlautotranslation.res ($Lazarus)\lcl\languages\lclstrconsts.nl.po See also this topic. Bart ---------------------------------------------------------------------- wp · 2023-10-13 22:06 Nice idea. Would be great if this procedure were included in "Translations". ---------------------------------------------------------------------- loaded · 2023-10-14 06:11 Thanks to you, I learned something new too. I would like to thank my brother Onur for the "lclstrconsts.tr.po" file. I give 1 Like to wp and Bart for this nice solution. ---------------------------------------------------------------------- Zvoni · 2023-10-16 07:14 Quote from: Bart on October 13, 2023, 11:54:51 pmIf you have the .po file as a resource there is no need to store it temporarily, you can perform the translation from with the resource. An excerpt from one of my convenience units: The .res file is created with the lazres tool that comes with lazarus: Code: [Select]    ($Lazarus)\tools\lazres nlautotranslation.res ($Lazarus)\lcl\languages\lclstrconsts.nl.po See also this topic. Bart Bart, thank you. Exactly what i was looking for. Adjusted to "de", added unit in  lpr-file, go! +1 Thx Zvoni