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)
|
|
|
|
_.changeLang(lang_locale)
|
|
|
|
G_reader_settings:saveSetting("language", lang_locale)
|
2014-01-18 17:23:55 +00:00
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("Please restart reader for new language setting to take effect."),
|
|
|
|
timeout = 3,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2014-01-19 17:59:27 +00:00
|
|
|
function Language:genLanguageSubItem(lang, lang_locale)
|
2014-01-18 17:23:55 +00:00
|
|
|
return {
|
|
|
|
text = lang,
|
|
|
|
callback = function()
|
2014-01-19 17:59:27 +00:00
|
|
|
self:changeLanguage(lang_locale)
|
2014-01-18 17:23:55 +00:00
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function Language:getLangMenuTable()
|
|
|
|
-- 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 = {
|
2014-01-18 22:04:14 +00:00
|
|
|
self:genLanguageSubItem("English", "C"),
|
2014-01-18 17:23:55 +00:00
|
|
|
self:genLanguageSubItem("čeština", "cs_CZ"),
|
|
|
|
self:genLanguageSubItem("Deutsch", "de"),
|
|
|
|
self:genLanguageSubItem("français", "fr"),
|
|
|
|
--self:genLanguageSubItem("magyar", "hu"),
|
|
|
|
self:genLanguageSubItem("Italiano", "it_IT"),
|
|
|
|
self:genLanguageSubItem("język polski", "pl"),
|
|
|
|
self:genLanguageSubItem("Português do Brasil", "pt_BR"),
|
|
|
|
self:genLanguageSubItem("Русский язык", "ru"),
|
|
|
|
--self:genLanguageSubItem("svenska", "sv"),
|
|
|
|
self:genLanguageSubItem("Türkçe", "tr"),
|
|
|
|
--self:genLanguageSubItem("Tiếng Việt", "vi"),
|
|
|
|
self:genLanguageSubItem("简体中文", "zh_CN"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
return self.LangMenuTable
|
|
|
|
end
|
|
|
|
|
|
|
|
return Language
|