![]() |
How to Localize Delphi FireMonkey Applications |
This tutorial shows how to localize your Delphi FireMonkey application using Soluling.
Before you can start localizing your VCL application, you need to perform the following step:
Once you have done the above step, you can create a Soluling project file.
Start Soluling. Click New from File or Files button in the main view or drag and drop your Delphi project file (.dproj) on the main view. Soluling start the Project Wizard that collects the information needed to create a new Soluling project. The first sheet of the wizard is the Options sheet.
Click Next. The Select Languages sheet appears.
Add the languages you want to localize. Later you can add new languages at any time. Set the original language of your original language. Click Finish to complete the wizard.
Now your project is created, and you can start translating it.
Follow the general translate instructions to translate your project. When you have translated the project, you can build the localized files.
When you build the project, the output file is a single multilingual resource file (NtLangRes.ntres
) that contains the form, strings, and other resources in the languages you have in the Soluling project file. You have two choices to use the translation file in your application.
Add the NtLangRes.ntres
resource file as a custom RCDATA resource into your Delphi project. Choose Project | Resource, and Images from Delphi.
Make sure the resource identifier is NtLangRes. Add the NtResource unit, call _T function for each form, and compile your project. Now it is multilingual and enabled for the runtime language change. FireMonkey localization can also be used in VCL projects.
Another choice is to use the resource file as a standalone file. Typically you first either deploy or download the file to a directory. Then, in your application code, set the NtResources.ResourcePath
property. This must be set before any form gets created. A good place is the initialization section of the main form.
initialization NtResources.ResourcePath := '/Documents/Donwloaded/NtLangRes.ntres'; end.
Note! All the platforms (iOS, Android, etc.) of Delphi use the same .ntres file, but the file paths are very platform-specific, so you most likely need to use conditional compiling.
If you don't specify the ResourcePath, Soluling code will try to find the file from directory returned by TPath.GetDocumentsPath
(Delphi's RTL code). The directory is platform specific:
OS | Directories | Notes |
---|---|---|
Windows | The same directory as the application EXE |
If you application is C:\Files\Project1.exe then Soluling code first looks for C:\Files\NtLangRes.ntres. If not found then looks for Documents/Project1/NtLangRes.ntres If the project specific document directory does not exist then looks for Documents/NtLangRes.ntres |
macOS | /Users/<user>/Documents/<applicationname> /Users/<user>/Documents |
|
iOS | ||
Android | /data/data/com.embacadero.<applicationname>/files | |
Linux |
<applicationname> is the filename of your application without the extension
In addition to the multilingual resource file (.ntres
), Soluling can also create language-specific resource files (.ntlang
). You can deploy these files instead of the .ntres
file. This makes it possible to add new languages without changing any installed file. To make Soluling create .ntlang
files, check either Languages specific resource files or Both in Output file type group box in the Delphi build options sheet.
If you set the ResourcePath property, set only the directory part. for example.
initialization NtResources.ResourcePath := '/Documents/Donwloaded'; end.
Soluling code then tries to find all .ntlang
file in that directoru and uses them.