burnersk
Posts: 43
Joined: Mon Mar 25, 2019 12:26 pm

How to retrieve the installers language and store it into the registry as a two letter ISO code?

Tue Feb 04, 2020 9:33 am

I have authored a multi-language setup (all in one MSI). The user can choose the language based on Advanced Installers stock feature (no own implementation).

Now, I want to save the installers language into a registry key as an ISO 3166 ALPHA-2 (e.g. "ro" for Romania, "gb" for Great Britain, "de" fpr Germany) value.

How can I accomplish this? I saw a language related property, but it holds a number with a complex matrix of country, region, locale, language, etc..

Catalin
Posts: 6542
Joined: Wed Jun 13, 2018 7:49 am

Re: How to retrieve the installers language and store it into the registry as a two letter ISO code?

Tue Feb 04, 2020 3:21 pm

Hello,

Unfortunately, we do not have predefined support for such a task.

However, it is still possible to achieve this.

The property that stores the language is named ProductLanguage and it is represented by a numeric value, whose meaning can be found in the "ProductLanguage Property" article.

Basically, here, we will have a little script which will do the work for us. What we need to do in the script:

- get the value of the ProductLanguage property

- based on this, set a variable to our desired value (e.g. "Ro", "En", etc.)

- set a property to the above mentioned variable's value

- write the property in the registries

Here is a sample of how our script could look like:

Code: Select all

$langMSI = AI_GetMsiProperty ProductLanguage

switch ($langMSI) {

1033 {$language = "En"}
1036 {$language = "Fr"}

}

AI_SetMsiProperty SELECTED_LANGUAGE $language
The above script can be implemented in Advanced Installer as a PowerShellScriptInline custom action, without sequence.

After doing so, please go to "Dialogs" page, select the "WelcomeDlg" dialog and then select the "Next" button. Here, under "Published Events" tab, please click on the "New..." button to add an event as it follows:

Event: Execute Custom Action
Argument: PowerShellScriptInline (or however you named the custom action)
Condition: leave unchanged


Now please go to "Registry" page and add a new value there, based on the property we've previously set in our script (i.e. SELECTED_LANGUAGE).

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”