araucano2010
18th March 2011 15:01 UTC
Language-dependent shortcuts
Hi,
I'd like to create different shortcuts based on the selected language. Here's the code I'd like to use, but it's not working:
${If} ${LANGUAGE} == ${LANG_ENGLISH}
CreateShortCut "$DESKTOP\MyProgram.lnk" "$INSTDIR\MyProgram.exe" "1"
${ElseIf} ${LANGUAGE} == ${LANG_SPANISHINTERNATIONAL}
CreateShortCut "$DESKTOP\MyProgram.lnk" "$INSTDIR\MyProgram.exe" "2"
${Else}
CreateShortCut "$DESKTOP\MyProgram.lnk" "$INSTDIR\MyProgram.exe" "3"
${EndIf}
It always create the shortcut with the "3" parameter (I guess there's something wrong in the If clause, but I cannot figure it out)
jiake
18th March 2011 15:27 UTC
Replace == with =, and ${LANG_ENGLISH} with 1033, and then try again.
demiller9
18th March 2011 15:46 UTC
You are testing at run-time, you should be examining the variable $LANGUAGE, not a define set at compile-time called ${LANGUAGE}.
Afrow UK
18th March 2011 16:10 UTC
And it is perfectly fine to use ${LANG_ENGLISH} and == should work fine (it uses StrCmp).
Stu
araucano2010
18th March 2011 20:18 UTC
Thanks a lot :) It works like a charm like this:
${If} $LANGUAGE == ${LANG_ENGLISH}
CreateShortCut "$DESKTOP\MyProgram.lnk" "$INSTDIR\MyProgram.exe" "1"
${ElseIf} $LANGUAGE == ${LANG_SPANISHINTERNATIONAL}
CreateShortCut "$DESKTOP\MyProgram.lnk" "$INSTDIR\MyProgram.exe" "2"
${Else}
CreateShortCut "$DESKTOP\MyProgram.lnk" "$INSTDIR\MyProgram.exe" "3"
${EndIf}
jiake
18th March 2011 22:56 UTC
I unexpectedly didn't find his error - ${LANGUAGE}. For comparation of pure numerical string, I prefer to use IntCmp not StrCmp. I suggest to replace ${LANG_ENGLISH} with 1033, for that I really met this problem before: LangString STRNAME ${LANG_ENGLISH} ... does not work, but: LangString STRNAME 1033 ... works, I even thought whether NSIS has discarded these constants.
Afrow UK
19th March 2011 18:34 UTC
The LANG_ defines work fine for me. You just need to use them after they are defined - i.e. after where you've included the language.
Stu