[fpc-pascal] Localized version of my application
Mattias Gaertner
nc-gaertnma at netcologne.de
Sun Jul 6 16:57:27 CEST 2008
On Sun, 06 Jul 2008 16:11:48 +0200
csanyipal at gmail.com (Csányi Pál) wrote:
> Hello!
>
> I have installed Lazarus Version #: 0.9.25 beta Date: 2008-06-18 and
> FPC Version: 2.2.0 SVN Revision: 15441M i386-linux-gtk 2 (beta).
>
> I made a small project with Lazarus with one Frame, Buttons, Labels
> and StaticTexts. All these elements have English text as Caption.
>
> I wish to localize this application to Hungarian language.
>
> Following the
>
> http://wiki.lazarus.freepascal.org/Translations_/_i18n_/\
> _localizations_for_programs
>
> tutorial I have now the project.po, project.mo, project.hu.po,
> project.hu.mo files.
>
> In this project I have source files: project.lpr and
> projectunit1.pas.
>
> project.lpr uses unit projectunit1.pas.
>
> I put the code that should to call TranslateUnitResourceStrings of the
> LCL translations unit in the project.lpr file:
>
> ------------>
> program projectunit1;
>
> {$mode objfpc}{$H+}
>
> uses
> {$IFDEF UNIX}{$IFDEF UseCThreads}
> cthreads,
> {$ENDIF}{$ENDIF}
> Interfaces, // this includes the LCL widgetset
> Forms
> { you can add units after this }, projectunit1,
> gettext, translations;
>
> {$IFDEF WINDOWS}{$R projectunit1}{$ENDIF}
>
> var
> PODirectory, Lang, FallbackLang: String;
>
> begin
> Application.Title:='project';
> Application.Initialize;
> Lang := '';
> FallbackLang := '';
> PODirectory := 'locales/';
> //projectdirectory/locales/
> GetLanguageIDs(Lang, FallbackLang); // in unit gettext
> TranslateUnitResourceStrings('project', PODirectory +
> 'project.%s.po', Lang, FallbackLang);
> Application.CreateForm(TForm1, Form1);
> Application.Run;
> end.
> ------------<
>
> This dosn't works.
>
> Localization is not so simple as I think?
>
> Please give me some advice what should I do now to get localized my
> application?
>
> I tried to add a Breakpoint after
>
> GetLanguageIDs(Lang, FallbackLang); // in unit gettext
>
> line to see wether Lang and FallbackLang variables get some values,
> but I don't know where to find this values after the run of the
> project stop at this point?
>
> Any advice will be appreciated!
Some work has been done on automatic storing the forms strings into .po
files and reading them back again. But there are many things left to
do. That's why there is only a simple unit (lcl/defaulttranslator.pas)
to load the strings. And this comes without documentation and has
several limitations.
Maybe it's better to use ResourceStrings.
Mattias
More information about the fpc-pascal
mailing list