Returns a preference value as a string.
1 | system.getPreference( category, name ) |
print( system.getPreference( "locale", "country" ) ) -- print the country
category
Valid values of category are: "ui" and "locale"
name
Valid values of name for "ui" category is: "language"
Valid values of name for "locale" category is: "country", "identifier", and "language".
String of parameter requested.
Fairly easy to find out yourself:
1 2 3 4 | print("ui.language",system.getPreference( "ui", "language" )) print("locale.country",system.getPreference( "locale", "country" )) print("locale.identifier",system.getPreference( "locale", "identifier" )) print("locale.language",system.getPreference( "locale", "language" )) |
output:
1 2 3 4 | ui.language en locale.country CA locale.identifier en_CA locale.language en |
Ok, but what about other languages, locales? I need to prepare an application for potentially many localized resources. I would like to give to a localizator/translator exact locale/language parameter for example for Thailand.
Maybe there could be link to the some ISO standard?
@radim.havriant
Actually I already use ISO 639-1. But since this is not mentioned in documentation, I have no guarantee, which result I can get. For example, if you call
1 | system.getPreference( "ui", "language" ) |
The information returned by this API is the information received from the OS. For details of what is returned, refer to the OS (iOS or Android) documentation.
is there anybody can help me?
I couldn't get system.getPreference ("ui", "language")..
If I call it on Android, I expect to get something like "english" but "1042" is what I got..
do I need some kind of "android.permission" ?
dev01,
system.getPreference ("ui", "language") get a language system generated by the system.
In iOS/Mac, you will receive something like "pt-BR" ou "en".
In Windows (simulator), you will receive something like 1046 or 1042. This is LCID code. Each country has it own code. You can find it here:
http://technet.microsoft.com/en-us/library/dd346950.aspx
In Android, depends: usually, you will receive the language name, as "english" or "português". I wrote "português" in portuguese, because you will receive the language name in portuguese (português), not in english (portuguese).
Sorry about my english.
Please, add more info about parameters. For example, what values may be returned.