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")
|
|
|
|
|
|
|
|
Language = {}
|
|
|
|
|
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{
|
|
|
|
text = _("Please restart reader for new language setting to take effect."),
|
|
|
|
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"),
|
|
|
|
self:genLanguageSubItem("čeština", "cs_CZ"),
|
|
|
|
self:genLanguageSubItem("Deutsch", "de"),
|
|
|
|
self:genLanguageSubItem("français", "fr"),
|
2014-05-24 13:46:06 +00:00
|
|
|
self:genLanguageSubItem("magyar", "hu"),
|
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"),
|
2014-05-24 13:46:06 +00:00
|
|
|
self:genLanguageSubItem("Nederlands", "nl_NL"),
|
2014-03-13 13:52:43 +00:00
|
|
|
self:genLanguageSubItem("Polski", "pl"),
|
|
|
|
self:genLanguageSubItem("Português do Brasil", "pt_BR"),
|
|
|
|
self:genLanguageSubItem("Русский язык", "ru"),
|
2014-06-01 13:23:47 +00:00
|
|
|
self:genLanguageSubItem("Español", "es"),
|
2014-06-05 12:13:20 +00:00
|
|
|
self:genLanguageSubItem("Catalá", "ca"),
|
2014-05-24 13:46:06 +00:00
|
|
|
-- self:genLanguageSubItem("svenska", "sv"),
|
2014-03-13 13:52:43 +00:00
|
|
|
self:genLanguageSubItem("Türkçe", "tr"),
|
2014-10-07 05:23:46 +00:00
|
|
|
self:genLanguageSubItem("Українська", "uk"),
|
2014-05-24 13:46:06 +00:00
|
|
|
-- self:genLanguageSubItem("Tiếng Việt", "vi"),
|
|
|
|
-- self:genLanguageSubItem("Viet Nam", "vi_VN"),
|
2014-03-13 13:52:43 +00:00
|
|
|
self:genLanguageSubItem("简体中文", "zh_CN"),
|
2014-06-05 12:13:20 +00:00
|
|
|
self:genLanguageSubItem("한글", "ko_KR"),
|
2014-03-13 13:52:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
return self.LangMenuTable
|
2014-01-18 17:23:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return Language
|