Multiple Languages

NSIS

Previous | Contents | Next

4.10 Multiple Languages

As of version 2 NSIS fully supports multiple languages. The interface of one installer can support multiple languages.

Use LoadLanguageFile for every language to load the default interface texts and language properties.

The default interface texts can easily be changed using instructions like ComponentText etc.

You can also use the contents of the standard language strings in your own strings (for example, $(^Name) contains the installer's name set using the Name instruction). The names of all standard language strings are listed as comments just above the strings in the language files. The language files are located in Contrib\Language Files.

To create your own language strings, use LangString.

For an example of an installer with multiple languages, see languages.nsi.

4.10.1 Language Selection

When the installer starts up it goes through these steps to select the interface language:

  1. Get user's default Windows UI language
  2. Find a perfect match for the language
  3. If there is no perfect match, find a primary language match
  4. If there is no match, use the first language defined in the script (make sure your first language is a common one like English)
  5. If the language variable $LANGUAGE has changed during .onInit, NSIS goes through steps 2 to 4 again.

4.10.2 LangDLL Plug-in

The LangDLL plug-in allows you to give the user an option to choose the language of the installer. Just push the language id (${LANG_langfile}) and its name for every language in your installer, then the number of languages pushed, the caption, and the text that tells the user to select the language, call the plug-in function named LangDialog, pop the returned value into $LANGUAGE and you're good to go. If the user clicks on the cancel button the return value will be "cancel".

For an example of usage see languages.nsi.

4.10.3 RTL Languages

RTL languages are languages that are written from right to left (e.g. Arabic and Hebrew). NSIS fully supports RTL languages. In the language file there is a place to specify if the language is RTL or not. To find out at runtime if the current language is RTL or not, check the value of the $(^RTL) language string. It will be 1 if the language is RTL and 0 otherwise. This can be useful when using plug-ins that create dialogs, they usually have RTL settings too.

Previous | Contents | Next