![]() |
Lazarus Localization and Internationalization |
Lazarus (Wikipedia) is an open-source Pascal IDE to create Windows, macOS, and Linux applications with Free Pascal. Lazarus uses the PO format to store the strings of the forms and resource strings. Soluling Desktop and Soluling Cloud support Lazarus PO files.
The end of the document contains links to get the full source code of the samples. After reading this document, we recommend reading a tutorial about how to use Soluling.
Start Lazarus and open your project. Choose Project | Project Options and select the i18n page. Check Enable i18n.

If you want to have the language files in a subdirectory, enter the name of the directory in PO Output Directory, for example, languages. If you leave it empty, the .pot and .po files are in the project directory.
Add the DefaultTranslator unit (or LCLTranslator that it uses) to the uses section of your main form. Use resourcestring strings in your code whenever you want to localize a string.
uses ..., DefaultTranslator; resourcestring SHello = 'Hello World';
Build the project. When i18n is enabled, Lazarus writes all the strings from your form files and resource strings into a .pot file (e.g., simple.pot) in the PO output directory. This file is the original file that you localize. Lazarus updates it every time you build the project.
When the application starts, DefaultTranslator looks for the PO file of the language of the operating system. The file must be named <application>.<language>.po, for example, simple.fi.po, and it must be in the application directory or in a languages or locale subdirectory of it. Deploy the localized PO files with your application.
To run your application in a specific language, enter
<yourapp> --lang <locale>
where the lang option specifies the language. To run simple.exe in Finnish, enter
simple.exe --lang fi
You can also change the language in code, for example, from a language menu, with SetDefaultLang of the LCLTranslator unit.
uses
LCLTranslator;
...
SetDefaultLang('fi');
.pot file (e.g., simple.pot) on Soluling or click the New from File or Files button and select the file.<file>.<language>.po name in the same directory as the .pot file, for example, simple.fi.po. Set the output file name on the Output sheet.
When you change the strings, build the project in Lazarus to update the .pot file, open the Soluling project, and choose Home | Scan. Soluling keeps the existing translations, and you only translate the strings that were added or changed.
With Soluling Cloud, you localize the .pot file in your browser: upload the file, translate it in Translate, and download the localized PO files. You need a Soluling account. See the available Cloud plans.
.pot file (e.g., simple.pot), or drag and drop the file onto the page. Click Create.Click the project's green Translate button on the dashboard. Translate opens the project, and you can type the translations into the grid. Machine translation suggestions, translation memory, and spell checking are available there. You do not have to finish every language before moving on to the next step.
.pot file with a download button for each target language. Save each localized file next to the .pot file as <application>.<language>.po, for example, simple.fi.po.When you have built the project in Lazarus and the .pot file has changed, upload the new file, translate what is new or changed, and download the localized files again. On the dashboard, click the project's Update file button (the upload arrow), select the new file or drop it onto the page, and click Update. Existing translations are kept, so you only translate the strings that were added or changed.
The dashboard is one of four ways to use Soluling Cloud. You can also use the SoluCLI command-line tool, Soluling Desktop, or SoluMake, which can run the update and build steps in your build pipeline. See the Cloud tutorial for all of them.
GitHub and <data-dir>\Samples\Lazarus contain the following samples:
| Directory | Description | Notes |
|---|---|---|
| Simple | A simple application with two forms and a resource string. Contains the Lazarus project, the original simple.pot, the Soluling project, and the localized Finnish simple.fi.po. | Try this first! |
In addition, the PO, PHP, and Python samples show how to localize PO files.
You can configure how to localize your Lazarus PO file by selecting the item in the project tree, right-clicking, and choosing the Options menu. A source dialog appears that lets you edit the options. This source uses the following option sheets.