mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
automatically set language on Android
This commit is contained in:
Submodule android/luajit-launcher updated: 5bd850e1e5...9c3178079c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user