-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathcommon.lua
More file actions
29 lines (28 loc) · 1.08 KB
/
common.lua
File metadata and controls
29 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function get_local_lang()
--local config = platform.get_config_info()
local local_lang = "en" -- Default language
-- TODO: config language by xlings.json
if is_host("linux") then
local tmp_local_lang = os.getenv("LANG") or "en"
if tmp_local_lang:find("zh") then
local_lang = "zh"
end
elseif is_host("windows") then
local tmp_local_lang = nil
if find_tool("wmic") then -- Windows 10 and earlier
-- wmic is deprecated in Windows 11, but still available
tmp_local_lang = os.iorun([[wmic os get locale]])
else -- win11+
tmp_local_lang = os.iorun([[powershell -NoProfile -ExecutionPolicy Bypass -Command "'{0:X4}' -f (Get-Culture).LCID"]])
end
if tmp_local_lang and tmp_local_lang:find("0804") then
local_lang = "zh"
end
elseif is_host("macosx") then
local tmp_local_lang = os.iorun([[defaults read -g AppleLocale]])
if tmp_local_lang and tmp_local_lang:find("zh") then
local_lang = "zh"
end
end
return local_lang
end