GetSystemLanguage() return value

Discuss any general programming issues here
Post Reply
User avatar
NubeCheCorre
Posts: 56
Joined: Mon Mar 19, 2012 1:24 am
Contact:

GetSystemLanguage() return value

Post by NubeCheCorre » Fri Aug 16, 2019 12:47 am

I am using Hollywood version 6.0 to create a very simple installation script.. I was looking for a way to get the system language used by the user that run my script and in the hollywood guide I found this function:

lang$ = GetSystemLanguage()

In the doc there is written that at the moment this function support the following languages:

#LANGUAGE_CROATIAN
#LANGUAGE_CZECH
#LANGUAGE_DANISH
#LANGUAGE_DUTCH
#LANGUAGE_ENGLISH
#LANGUAGE_FINNISH
#LANGUAGE_FRENCH
#LANGUAGE_GERMAN
#LANGUAGE_GREEK
#LANGUAGE_HUNGARIAN
#LANGUAGE_ITALIAN
#LANGUAGE_NORVEGIAN
#LANGUAGE_POLISH
#LANGUAGE_PORTUGUESE
#LANGUAGE_RUSSIAN
#LANGUAGE_SPANISH
#LANGUAGE_SWEDISH
#LANGUAGE_TURKISH
#LANGUAGE_UNKNOWN

For me, all these languages are enough, as I need to detect these three following languages: Italian, French and English.
But when I print the variable with the Print() function it returns a number instead of a string. So how can I know which is the system language used by the user? is there another function to use or am I missing something or doing it in the wrong way?

Thanks in advance for the help!

User avatar
jPV
Posts: 279
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: GetSystemLanguage() return value

Post by jPV » Fri Aug 16, 2019 7:34 am

You can compare the result from GetSystemLanguage() to those constants to figure out which language is in use.

For example like this:

Code: Select all

lang = GetSystemLanguage()
Switch lang
Case #LANGUAGE_ITALIAN:
    ; Do your Italian stuff here.
Case #LANGUAGE_FRENCH:
    ; Do your French stuff here.
Default:
    ; Do it in English.
EndSwitch
Or use GetLanguageInfo() to get the language in written forms:

Code: Select all

t = GetLanguageInfo(lang)
DebugPrint(t.Code, t.Name) 

Bugala
Posts: 823
Joined: Sun Feb 14, 2010 7:11 pm

Re: GetSystemLanguage() return value

Post by Bugala » Fri Aug 16, 2019 8:27 am

To clarify a bit just in case you are not familiar with this.

for example #LANGUAGE_FINNISH is a constant, which means that it is some number.

It is basically same as

x=1

x+4=5

except that the value of variable x can change, for example

x=1
debugprint(x)
x=2
debugprint(x)


however, constant (const) always stays the same. Once you define it, it can't be changed anymore.

So in practice getsystemlanguage() returns a number, but for easier human readability, these numbers have also consts assigned to them.

this is not a real example, but just as an example:

These consts might represent for example #LANGUAGE_FINNISH is number 3.

Similarly in makebutton command, #SIMPLEBUTTON constant might also represent 3.

therefore you could even do the language comparison against "wrong" constants, in way of: is getsystemlanguage "#SIMPLEBUTTON"? if yes, then language = Finnish.

User avatar
NubeCheCorre
Posts: 56
Joined: Mon Mar 19, 2012 1:24 am
Contact:

Re: GetSystemLanguage() return value

Post by NubeCheCorre » Fri Aug 16, 2019 3:24 pm

Thanks to both for the explanations and the examples :-)

Post Reply