You are here

More Useful Code: Language Reading/Setting

OliverK's picture
Submitted by OliverK on November 21, 2008 - 2:32pm

Here's the code I used for PNotes/ATPad.

They set the language through a file name, not using the environmental variables or using international language codes.

                ReadEnvStr $APPLANGUAGE "PortableApps.comLanguageCode"

                  StrCmp $APPLANGUAGE de Deutsch
                  StrCmp $APPLANGUAGE en_us English
                  StrCmp $APPLANGUAGE es_la Spanish
                  StrCmp $APPLANGUAGE it Italian
                  StrCmp $APPLANGUAGE jp Japanese
                  StrCmp $APPLANGUAGE pl Polski
                  StrCmp $APPLANGUAGE pt Portugese
                  StrCmp $APPLANGUAGE ru Russian English

                          StrCpy $APPLANGUAGE deutsch
                          Goto GetCurrentLanguage
                          StrCpy $APPLANGUAGE english
                          Goto GetCurrentLanguage
                          StrCpy $APPLANGUAGE spanish
                          Goto GetCurrentLanguage
                          StrCpy $APPLANGUAGE italian
                          Goto GetCurrentLanguage
                          StrCpy $APPLANGUAGE japanese
                          Goto GetCurrentLanguage
                          StrCpy $APPLANGUAGE polski
                          Goto GetCurrentLanguage
                          StrCpy $APPLANGUAGE portugese
                          Goto GetCurrentLanguage
                          StrCpy $APPLANGUAGE russian
                          Goto GetCurrentLanguage

                ReadINIStr $0 "$EXEDIR\Data\settings\Settings.ini" "lang" "Language"
                StrCmp "$APPLANGUAGE.lng" $0 LaunchNow ;if the same, move on
                IfFileExists "$EXEDIR\PNotes\lang\$APPLANGUAGE.lng" SetAppLanguage LaunchNow
                WriteINIStr "$EXEDIR\Data\settings\Settings.ini" "lang" "Language""$APPLANGUAGE.lng"

Anywho, thought you might like another coding tidbit.


TaffinFoxcroft's picture

you spelt language wrong on these lines:

ReadINIStr $0 "$EXEDIR\Data\settings\Settings.ini" "lang" "Lanuage"
WriteINIStr "$EXEDIR\Data\settings\Settings.ini" "lang" "Lanuage""$APPLANGUAGE.lng"

was there some meaning to this, or was it a typo by lamer when writing the INI reading part of PNotes? Biggrin
but anyway, enough of the criticism. thanks for this, its going into HM NIS Edit Portable as i write.

But there’s no sense crying over every mistake,
You just keep on trying till you run out of cake.

OliverK's picture

Criticism good, someone might not have caught it, like me :(.

Actually, I kinda generalized it from the instances in PNotes/ATPad. Anywho, thanks and I 'll fix it.

Too many lonely hearts in the real world
Too many bridges you can burn
Too many tables you can't turn
Don't wanna live my life in the real world