Forum > Translations
Translation and ShowMessage
(1/1)
Philippe1:
Hello,
I have an application which is very well localized for each caption / text of labels, TEdit, TMaskEdit, Buttons etc. The .po files are correct (path = /languages) eg for French :
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
#: tform1.btcalculate.caption
msgid "Calculate"
msgstr "Calculer"
.../...
I Have :
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Windows, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, IniFiles, LCLTranslator,
Graph, RegExpr, StdCtrls, ExtCtrls, MaskEdit, LCLType, LCLIntf, Variants, Math;
I can't figure out how to translate a string which is to be shown by ShowMessage : ShowMessage('my text to be translated').
Is there someone to help me ?
Thanks
Philippe
mig-31:
Hi,
to translate button caption you should copy lclstrconsts.fr.po from <lazarus installation dir>/lcl/languages to /languages and load it during app start up <your project>.lpr file
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program xxx;{$mode objfpc}{$H+} uses {$IFDEF UNIX} cthreads,clocale, {$ENDIF} Interfaces, // this includes the LCL widgetset Forms, main, tachartlazaruspkg, about, lazutf8, Translations, SysUtils; procedure TranslateLCL;var PODirectory, Lang, FallbackLang: String;begin PODirectory:= ExtractFilePath(Application.ExeName) +'languages/'; Lang:=''; FallbackLang:=''; LazGetLanguageIDs(Lang,FallbackLang); Translations.TranslateUnitResourceStrings('LCLStrConsts', PODirectory+'lclstrconsts.%s.po',Lang,FallbackLang); Translations.TranslateUnitResourceStrings('lr_const', PODirectory+'lr_const.%s.po',Lang,FallbackLang);end; {$R *.res} begin Application.Title:='xxx'; TranslateLCL; RequireDerivedFormResource := True; Application.Initialize; Application.CreateForm(TMainForm, MainForm); Application.Run;end.
To translate string in the MessageBox Add resourcestring after var with string which you want to show in the MessageBox:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---resourcestringMyMessageBoxStr = 'My message'; ShowMessage(MyMessageBoxStr); Find it in the .po file and translate to French.
Navigation
[0] Message Index