2014-01-18 17:23:55 +00:00
|
|
|
|
-- high level wrapper module for gettext
|
|
|
|
|
|
|
|
|
|
local InfoMessage = require("ui/widget/infomessage")
|
2017-04-29 14:30:16 +00:00
|
|
|
|
local UIManager = require("ui/uimanager")
|
2014-01-18 17:23:55 +00:00
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
|
2015-04-27 00:49:27 +00:00
|
|
|
|
local Language = {}
|
2014-01-18 17:23:55 +00:00
|
|
|
|
|
2014-01-19 17:59:27 +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
|
|
|
|
|
|
2014-01-19 17:59:27 +00:00
|
|
|
|
function Language:genLanguageSubItem(lang, lang_locale)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return {
|
|
|
|
|
text = lang,
|
2014-06-08 06:09:59 +00:00
|
|
|
|
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"),
|
2016-11-22 19:23:37 +00:00
|
|
|
|
self:genLanguageSubItem("Catalá", "ca"),
|
|
|
|
|
self:genLanguageSubItem("Čeština", "cs_CZ"),
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self:genLanguageSubItem("Deutsch", "de"),
|
2016-11-22 19:23:37 +00:00
|
|
|
|
self:genLanguageSubItem("Español", "es"),
|
2018-03-14 15:02:35 +00:00
|
|
|
|
self:genLanguageSubItem("Euskara", "eu"),
|
2016-11-22 19:23:37 +00:00
|
|
|
|
self:genLanguageSubItem("Français", "fr"),
|
2014-06-01 13:23:47 +00:00
|
|
|
|
self:genLanguageSubItem("Galego", "gl"),
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self:genLanguageSubItem("Italiano", "it_IT"),
|
2016-11-22 19:23:37 +00:00
|
|
|
|
self:genLanguageSubItem("Magyar", "hu"),
|
2014-05-24 13:46:06 +00:00
|
|
|
|
self:genLanguageSubItem("Nederlands", "nl_NL"),
|
2017-03-21 10:19:59 +00:00
|
|
|
|
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"),
|
2017-03-21 10:19:59 +00:00
|
|
|
|
self:genLanguageSubItem("Português do Brasil", "pt_BR"),
|
2019-02-04 08:33:45 +00:00
|
|
|
|
self:genLanguageSubItem("Slovenčina", "sk"),
|
2017-03-20 17:50:25 +00:00
|
|
|
|
self:genLanguageSubItem("Svenska", "sv"),
|
2018-03-14 15:02:35 +00:00
|
|
|
|
self:genLanguageSubItem("Tiếng Việt", "vi"),
|
2016-11-22 19:23:37 +00:00
|
|
|
|
self:genLanguageSubItem("Türkçe", "tr"),
|
2017-03-21 10:19:59 +00:00
|
|
|
|
--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"),
|
2017-03-21 10:19:59 +00:00
|
|
|
|
self:genLanguageSubItem("Ελληνικά", "el"),
|
2017-03-20 17:50:25 +00:00
|
|
|
|
--self:genLanguageSubItem("فارسی", "fa"),
|
|
|
|
|
self:genLanguageSubItem("日本語", "ja"),
|
|
|
|
|
--self:genLanguageSubItem("Қазақ", "kk"),
|
|
|
|
|
self:genLanguageSubItem("한글", "ko_KR"),
|
2016-11-22 19:23:37 +00:00
|
|
|
|
self:genLanguageSubItem("Русский язык", "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
|