2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00
koreader/frontend/ui/language.lua

78 lines
3.2 KiB
Lua
Raw Normal View History

2014-01-18 17:23:55 +00:00
-- high level wrapper module for gettext
local UIManager = require("ui/uimanager")
local InfoMessage = require("ui/widget/infomessage")
local _ = require("gettext")
2015-04-27 00:49:27 +00:00
local Language = {}
2014-01-18 17:23:55 +00:00
function Language:changeLanguage(lang_locale)
2014-03-13 13:52:43 +00:00
_.changeLang(lang_locale)
G_reader_settings:saveSetting("language", lang_locale)
UIManager:show(InfoMessage:new{
2014-11-12 11:29:38 +00:00
text = _("Please restart KOReader for the new language setting to take effect."),
2014-03-13 13:52:43 +00:00
timeout = 3,
})
2014-01-18 17:23:55 +00:00
end
function Language:genLanguageSubItem(lang, lang_locale)
2014-03-13 13:52:43 +00:00
return {
text = lang,
checked_func = function()
return G_reader_settings:readSetting("language") == lang_locale
end,
2014-03-13 13:52:43 +00:00
callback = function()
self:changeLanguage(lang_locale)
end
}
2014-01-18 17:23:55 +00:00
end
function Language:getLangMenuTable()
2014-03-13 13:52:43 +00:00
-- cache menu table
if not self.LangMenuTable then
self.LangMenuTable = {
text = _("Language"),
-- NOTE: language with no translation are commented out for now
sub_item_table = {
self:genLanguageSubItem("English", "C"),
self:genLanguageSubItem("Catalá", "ca"),
self:genLanguageSubItem("Čeština", "cs_CZ"),
2014-03-13 13:52:43 +00:00
self:genLanguageSubItem("Deutsch", "de"),
self:genLanguageSubItem("Español", "es"),
self:genLanguageSubItem("Français", "fr"),
self:genLanguageSubItem("Galego", "gl"),
2014-03-13 13:52:43 +00:00
self:genLanguageSubItem("Italiano", "it_IT"),
self:genLanguageSubItem("Magyar", "hu"),
self:genLanguageSubItem("Nederlands", "nl_NL"),
self:genLanguageSubItem("Norsk", "nb_NO"),
2014-03-13 13:52:43 +00:00
self:genLanguageSubItem("Polski", "pl"),
2017-03-20 17:50:25 +00:00
--self:genLanguageSubItem("Polski2", "pl_PL"),
self:genLanguageSubItem("Português", "pt_PT"),
self:genLanguageSubItem("Português do Brasil", "pt_BR"),
2017-03-20 17:50:25 +00:00
self:genLanguageSubItem("Svenska", "sv"),
--self:genLanguageSubItem("Tiếng Việt", "vi"),
self:genLanguageSubItem("Türkçe", "tr"),
--self:genLanguageSubItem("Viet Nam", "vi_VN"),
2017-03-20 17:50:25 +00:00
--self:genLanguageSubItem("عربى", "ar_AA"),
self:genLanguageSubItem("български", "bg_BG"),
--self:genLanguageSubItem("বাঙালি", "bn"),
self:genLanguageSubItem("Ελληνικά", "el"),
2017-03-20 17:50:25 +00:00
--self:genLanguageSubItem("فارسی", "fa"),
self:genLanguageSubItem("日本語", "ja"),
--self:genLanguageSubItem("Қазақ", "kk"),
self:genLanguageSubItem("한글", "ko_KR"),
self:genLanguageSubItem("Русский язык", "ru"),
2017-03-20 17:50:25 +00:00
self:genLanguageSubItem("Русский", "ru_RU"),
self:genLanguageSubItem("Українська", "uk"),
2017-03-20 17:50:25 +00:00
--self:genLanguageSubItem("中文", "zh"),
2014-03-13 13:52:43 +00:00
self:genLanguageSubItem("简体中文", "zh_CN"),
2017-03-20 17:50:25 +00:00
self:genLanguageSubItem("中文(台灣)", "zh_TW"),
--self:genLanguageSubItem("中文台灣Big5", "zh_TW.Big5"),
2014-03-13 13:52:43 +00:00
}
}
end
return self.LangMenuTable
2014-01-18 17:23:55 +00:00
end
return Language