How to localize the value of a property based on the OS language?

ImportantThe following article uses options that are available starting with the Enterprise edition and project type.

To localize the value of a property based on the OS language, the following steps must be taken:

1. Open an existing Advanced Installer project or create a new one and select the default language.

ImportantThe Project's language is set in the "Start Page" by selecting it in the "Options" -> "Language" field and cannot be changed later.

2. Create the property you want to localize (for example from the Properties Page - Installer Project) and set the value for the default language. For example, if the project's language is English, this value will appear in the English version of the installer.

3. In this example we will use the MY_PROP property with its default value value.

4. On the left pane, under User Interface go to the Translations page and navigate to Languages Tab. Select the languages "English", "French" and "German" (this is just an example, you can select any languages you want).

5. Go to Properties page under Custom Behavior in the left pane and right click -> Edit Property on MY_PROP.

6. Right click in the Value: field box and click on Localization...

7. Make sure that the "Always translate this string" and "Using specified localization identifier" options are selected.

8. Make sure that the localization identifier is set to Property.MY_PROP.

9. Go to the Project Strings Tab from the Translations page and click the [ Select... ] button localized on the bottom right .

10. In the "Localization Options" dialog check the Properties option.

ImportantThere are two ways of translating project strings to a custom dictionary and including it into your project. One involves using Advanced Installer's predefined dictionary editor from the Project Strings Tab -> "Project Strings" section. The other involves manually editing the dictionary file and is described in this article.

11. In the same tab click on the [ Create... ] button.

12. Follow the wizard and create a custom dictionary ("example.ail") based on the "English" language.

13. Open the generated dictionary with a text editor (that supports UFT-8 encoding, like Notepad) and find the Property.MY_PROP entry.

14. Set the desired values for lang=fr and lang=de like below:

<ENTRY id="Property.MY_PROP">
  <STRING lang="en" value="value"/>
    <STRING lang="fr" value="valeur"/>
    <STRING lang="de" value="wert"/>
  </ENTRY>
</DICTIONARY>

Where:

  • id="Property.MY_PROP" - is the identifier used to localize the property's value.
  • lang="eng" value="value" - is the value for English language. This is for reference only.
  • lang="fr" value="valeur" - is the value for French language.
  • lang="de" value="wert" - is the value for German language.

ImportantThe property's value for the English language (project's language) will be the one set in the project and not the one from the dictionary, because as you can see in the dictionary file on the second row, the English translation from the file is ignored: <DICTIONARY type="multi-language" ignore="en">

15. Save and close the dictionary file.

16. Save the project, close, reopen Advance Installer and load the project.

17. Rebuild and run the project.

Tip You can add more entries in the same dictionary for different values you want to localize. Therefore, it is strongly recommended to follow the above steps and create the dictionary after all the needed properties have been declared.