Archive: Language-dependent shortcuts


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)


Replace == with =, and ${LANG_ENGLISH} with 1033, and then try again.


You are testing at run-time, you should be examining the variable $LANGUAGE, not a define set at compile-time called ${LANGUAGE}.


And it is perfectly fine to use ${LANG_ENGLISH} and == should work fine (it uses StrCmp).

Stu


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}


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.


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