mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
strip encoding suffix in locale name like zh_CN.utf8
So that we can automatically change to language defined in the LANGUAGE or LANG env variable.
This commit is contained in:
@@ -39,7 +39,10 @@ function GetText_mt.__index.changeLang(new_lang)
|
||||
GetText.current_lang = "C"
|
||||
|
||||
-- the "C" locale disables localization alltogether
|
||||
if new_lang == "C" then return end
|
||||
if new_lang == "C" or new_lang == nil then return end
|
||||
|
||||
-- strip encoding suffix in locale like "zh_CN.utf8"
|
||||
new_lang = new_lang:sub(1, new_lang:find(".%."))
|
||||
|
||||
local file = GetText.dirname .. "/" .. new_lang .. "/" .. GetText.textdomain .. ".po"
|
||||
local po = io.open(file, "r")
|
||||
|
||||
Reference in New Issue
Block a user