Code: Select all
function getUserLang
local tAppLangs = "en,fr,de,es,it,pt,zh,zh,zh,zh,ja,ko,ru" --> LANGUAGE CODES THAT WILL BE RETURNED BY FUNCTION
local tAppLangsMac = "en,fr,de,es,it-IT,pt,zh-Hans,zh-Hant,zh_TW,zh_CN,ja,ko,ru" --> LANGUAGE CODES THAT MAC OS RETURNS
local tAppLangsWin = "9,12,7,10,16,22,4,4,4,4,17,18,25" --> DECIMAL REPRESENTATIONS OF PRIMARY LANGUAGE CODES WINDOWS RETURNS
local tUserLangs
local i
set wholeMatches to true
if platform() is "MacOS" then
put replaceText(shell("defaults read NSGlobalDomain AppleLanguages"),"(\s|\(|\))","") into tUserLangs
replace quote with "" in tUserLangs
repeat for each item tLang in tUserLangs
put itemOffset(tLang, tAppLangsMac) into i
if i > 0 then exit repeat
end repeat
else if platform() is "Win32" then
put queryRegistry("HKEY_CURRENT_USER\Control Panel\International\Locale") into tUserLangs
put baseConvert(tUserLangs,16,10) bitAND 1023 into tUserLangs
repeat for each item tLang in tUserLangs
put itemOffset(tLang, tAppLangsWin) into i
if i > 0 then exit repeat
end repeat
end if
if i > 0 then
return item i of tAppLangs
else
return "en"
end if
end getUserLang
Is there? Is any system var that can be used? If not it would be a great addition...
Regards