0 votes

Hi,

I try to get the language code of the current user in a serverscript to do something like

"select STATUS" + langue + " from LKOPPO_STATUS";

but if I use the Database.Language it only return "9".... that seems to correspond to ... nothing...

should I use a client side GetLanguage and pass the value to the server as a parameter?

It sure will work but is it really the best way to do that?

asked in Efficy/ Client side by (989 points)

1 Answer

0 votes
Best answer

Hello Louis.

There is a link with the language code used by Efficy and the Windows language, but after a few google searches, I also don't find the mapping table. Maybe R&D can help?

Anyway, you will have to translate the language integer into your language code yourselve.

For instance:

switch(Database.Language) {
  case  9: return "EN"; break;
  case 12: return "FR"; break;
  case 19: return "NL"; break;
  default: return "EN";
}
answered by (7.4k points)
selected by
I did try to execute a simple task with the schedulerAdmin.exe doing this :

Database.Log("Code: " + Database.Language);

Even if I did changed the user language in Conficy the result always was 9....

I don't know what language is return so.... Windows language? weird
I have no idea either what 9 is suppose to be. SchedulerAdmin is not the same context as a serverscript. A server script will take the language of the session
allright thanks Kristof
Here are the hexadecimal values and their corresponding language, so 9 = EN:
'AR' => 0x01: Arabic
'BG' => 0x02: Bulgarian
'CA' => 0x03: Catalan
'ZH' => 0x04: Chinese
'CS' => 0x05: Czech
'DA' => 0x06: Danish
'DE' => 0x07: German
'EL' => 0x08: Greek
'EN' => 0x09: English
'ES' => 0x0A: Spanish
'FI' => 0x0B: Finnish
'FR' => 0x0C: French
'HE' => 0x0D: Hebrew
'HU' => 0x0E: Hungarian
'IS' => 0x0F: Icelandic
'IT' => 0x10: Italian
'JA' => 0x11: Japanese
'KO' => 0x12: Korean
'NL' => 0x13: Dutch
'NO' => 0x14: Norwegian
'PL' => 0x15: Polish
'PT' => 0x16: Portugese
'RM' => 0x17: Rhaeto-Romanic
'RO' => 0x18: Romanian
'RU' => 0x19: Russian
'HR' => 0x1A: Croatian
'SK' => 0x1B: Slovak
'SQ' => 0x1C: Albanian
'SV' => 0x1D: Swedish
'TH' => 0x1E: Thai
'TR' => 0x1F: Turkish
'UR' => 0x20: Urdu
The switch in my code example is updated with the condition for ID=9 and English.
Anthony, we suggest to extend the serverside API to get the language code (2 letters), e.g. Database.languageCode()
Pascal made a new function "LanguageName" => available in Efficy 11 (March 2018)
Yeah, superb !!!
//-----(obsolete à partir de v11 utiliser Database.LanguageName)
function getLanguageName(_language){
    switch(_language) {
        case 1: return "AR"; break
        case 2: return "BG"; break
        case 3: return "CA"; break
        case 4: return "ZH"; break
        case 5: return "CS"; break
        case 6: return "DA"; break
        case 7: return "DE"; break
        case 8: return "EL"; break
        case 9: return "EN"; break
        case 10: return "ES"; break
        case 11: return "FI"; break
        case 12: return "FR"; break
        case 13: return "HE"; break
        case 14: return "HU"; break
        case 15: return "IS"; break
        case 16: return "IT"; break
        case 17: return "JA"; break
        case 18: return "KO"; break
        case 19: return "NL"; break
        case 20: return "NO"; break
        case 21: return "PL"; break
        case 22: return "PT"; break
        case 23: return "RM"; break
        case 24: return "RO"; break
        case 25: return "RU"; break
        case 26: return "HR"; break
        case 27: return "SK"; break
        case 28: return "SQ"; break
        case 29: return "SV"; break
        case 30: return "TH"; break
        case 31: return "TR"; break;
        case 32: return "UR"; break;
        default: return "EN";
    }
}
1,248 questions
1,518 answers
1,858 comments
328 users