Archive: keep the language user choose


keep the language user choose
Hello,

I am making an installer in several languages

So I use

;Languages     
!insertmacro MUI_LANGUAGE "English" ;first language is the default language
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Spanish"


I want to write a key in the register in function of the choice of the language. How can I do that? I mean, how can I do

if(user selected french)
WriteRegStr HKLM "Software\MySoft" "Language" "FR"
else if(user selected spanish)
WriteRegStr HKLM "Software\MySoft" "Language" "ES"
...

Thanks in advance for your help

Search the documentation for "Settings for registry storage of selected language"


Thanks jpderuiter for your answer!


Function .onInit

!insertmacro MUI_LANGDLL_DISPLAY

FunctionEnd


Just a question for the implementation. In the doc, it is written

To remember the user's preference, you can define a registry key. These defines should be set before inserting the installation page macro.
MUI_LANGDLL_REGISTRY_ROOT root
MUI_LANGDLL_REGISTRY_KEY key
MUI_LANGDLL_REGISTRY_VALUENAME value_name

The registry key to store the language. The users preference will be remembered. You can also use it for the uninstaller to display the right language. Don't forget to remove this key in the uninstaller.
I am a little confused. How should I defines this key

MUI_LANGDLL_REGISTRY_ROOT = HKLM
MUI_LANGDLL_REGISTRY_KEY = Language
MUI_LANGDLL_REGISTRY_VALUENAME = FR ?

and then write WriteRegStr MUI_LANGDLL_REGISTRY_ROOT MUI_LANGDLL_REGISTRY_KEY MUI_LANGDLL_REGISTRY_VALUENAME?

Can you give me a little example?

Thanks in advance

All you need to do is to define the three values.
No need for WriteRegStr.
See the MUI MultiLanguage example.


Thanks again jpderuiter

I have done some tests


!define MUI_LANGDLL_REGISTRY_ROOT HKLM
!define MUI_LANGDLL_REGISTRY_KEY "Software\MySoft"
!define MUI_LANGDLL_REGISTRY_VALUENAME "InstallerLanguage"


After the installation I have well the value written in the register (I had selected French for installation)

http://img23.imageshack.us/img23/5137/registerl.jpg

But I have read in an other post that we can used the $LANGUAGE in order to know the language that the user has choosen.

So I have tried to write

WriteRegStr HKLM "Software\MySoft" "Language" "${LANGUAGE}"


But here is the result
http://img16.imageshack.us/img16/264/register2l.jpg

Why is the value $LANGUAGE ant not FR ?

Thanks in advance

I have corrected the second point by replacing

WriteRegStr HKLM "Software\MySoft" "Language" "${LANGUAGE}"


by

WriteRegStr HKLM "Software\MySoft" "Language" "$LANGUAGE"


But is there a way to write for example FR instead of 1036 (for french)?. I mean, is it possible to write the tag of the language instead of the code of the language?

Thanks in advance

You can't with MUI as it is.
You'll have to modify the MUI plugin to do that.


Ok thanks for your reply. This is what I have finally done


${If} $LANGUAGE == 1031
WriteRegStr HKLM "Software\KeyLemon" "Language" "DE"
${ElseIf} $LANGUAGE == 1033
WriteRegStr HKLM "Software\KeyLemon" "Language" "EN"
${ElseIf} $LANGUAGE == 1034
WriteRegStr HKLM "Software\KeyLemon" "Language" "ES"
${ElseIf} $LANGUAGE == 1036
WriteRegStr HKLM "Software\KeyLemon" "Language" "FR"
${Else}
WriteRegStr HKLM "Software\KeyLemon" "Language" "EN"
${EndIf}


I get the language code here: http://www.science.co.il/language/Lo....asp?s=country

I just need a precision. I have seen that there is a full of different code for french or spain language for example

For example
French (France) 1036
French (Cameroon) 11276
French (Congo, DRC) 9228
French (Cote d'Ivoire) 12300
French (Mali) 13324 340c
French (Morocco) 14348
French (Senegal) 10252
French (West Indies) 7180
If the user choose french for installation. Can I be sure that the returned language code is 1036 or it could be another one?

Thanks in advance

Yes, if the user chooses french, the language code will be 1036.
It is defined in the French.nlf file in the Contrib\Language files folder of NSIS.