Localization


On the "General Settings->Languages" step, you configure the languages that are supported by your project. The following languages are available:

By default, only one language is shipped with the installer. This is called the principal language. By adding additional languages, you can build multi-language installers. If none of the configured languages match the locale at runtime, the principal language is used.

For multi-language installers, a language selection dialog is shown when the installer is started. By selecting the Skip language selection dialog check box you can choose to show the language selection only if the installer cannot find a match between a supported language and the auto-detected locale.

The principal language setting can be overridden for each media file on the "Customize project defaults->Principal language" step of the media wizard. In this way, you can build multiple fixed-language installers, each with a different principal language.

Localization mechanism

In projects, localized messages are obtained in one of two ways;

Custom localization

In addition to the standard messages that are displayed in the generated installer and uninstaller, you will have your own messages that need to be localized in the same way. To configure these messages, create a custom localization file for the principal language. A custom localization file is a text file with key-message pairs in the format of

You can create and edit custom localization files externally or directly in the install4j IDE with the built-in editor:

For each additional language, add a corresponding custom localization file that contains the same keys. If a message is missing for an additional language, the message for the principal language is used. The variable selection dialog for i18n messages will show all keys in the custom localization file for the principal language.

If any standard message in the installer is not appropriate for your purpose, you can override it by looking up the corresponding keys in the appropriate message file with the path

<install4j installation directory>/resource/messages/messages_*.utf8

and defining the same key in your custom localization file. The built-in editor has an "Override message" tool bar button that helps you to find the message of interest and inserts the key-value pair in the editor.

Parameters in i18n messages

If required, you can use parameters for your messages by using the usual {n} syntax in the value and listing the parameters with a function-like syntax after the key name. For example, if your key name is myKey and your message value is

Create {0} entries of type {1}

you can use a variable

${i18n:myKey("5", "foo")}

in order to fill the parameters, so that the actual message becomes

Create 5 entries of type foo

However, in the context of localizing an installer this is rarely necessary. Should you need to include a literal variable expression {n} in the message, you have to quote it like '{'n'}'.

Another way of adding parameters to i18n messages is to use compiler or installer variables. Compiler variables are replaced at build time and installer variables are replaced at runtime. For example:

messageWithCompilerVariable=Title for ${compiler:sys.fullName}
messageWithInstallerVariable=Installing to ${installer:sys.installationDir}