Contains classes and routines used to load/check/maintain translations from .po (portable object) files.

translations.pas contains classes and routines used to load/check/maintain translations from .po (portable object) files.

This file is part of the LazUtils package.

Initial authors: Mattias Gaertner, Bart Broersma, Giuliano Colla

Example 1: Load a specific .po file

procedure TForm1.FormCreate(Sender: TObject); var PODirectory: String; begin PODirectory := '/path/to/lazarus/lcl/languages/'; TranslateUnitResourceStrings('LCLStrConsts', PODirectory+'lcl.%s.po', 'nl', ''); MessageDlg('Title', 'Text', mtInformation, [mbOk, mbCancel, mbYes], 0); end;

Example 2: Load the current language file using the GetLanguageIDs function of the gettext unit in the project lpr file:

uses ... Translations, LCLProc;

procedure TranslateLCL; var PODirectory, Lang, FallbackLang: String; begin PODirectory := '/path/to/lazarus/lcl/languages/'; Lang := ''; FallbackLang:=''; LCLGetLanguageIDs(Lang, FallbackLang); // in unit LCLProc Translations.TranslateUnitResourceStrings('LCLStrConsts', PODirectory+'lclstrconsts.%s.po', Lang, FallbackLang); end;

begin TranslateLCL; Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end.

Note for Mac OS X:

The supported language IDs should be added into the application bundle property list to CFBundleLocalizations key, see lazarus.app/Contents/Info.plist for an example.

Lazarus resource string table in JSON format.
FPC resource string table (prior to FPC 2.7.1).
FPC resource string table in JSON format (since FPC 2.7.1).