automatically set language on Android

pull/634/head
chrox 10 years ago
parent 88061b323e
commit 20bd14d588

@ -1 +1 @@
Subproject commit 5bd850e1e57d4ceb1b867f3bc38a31a8795a9fe9
Subproject commit 9c3178079c8c46226c74717bfc16903535b4ee14

@ -1,3 +1,4 @@
local isAndroid, android = pcall(require, "android")
local DEBUG = require("dbg")
local GetText = {
@ -96,4 +97,16 @@ elseif os.getenv("LANG") then
GetText.changeLang(os.getenv("LANG"))
end
if isAndroid then
local ffi = require("ffi")
local buf = ffi.new("char[?]", 16)
ffi.C.AConfiguration_getLanguage(android.app.config, buf)
local lang = ffi.string(buf)
ffi.C.AConfiguration_getCountry(android.app.config, buf)
local country = ffi.string(buf)
if lang and country then
GetText.changeLang(lang.."_"..country)
end
end
return GetText

Loading…
Cancel
Save