yuuki/libs/i18n/__init__.py

28 lines
838 B
Python
Raw Normal View History

2019-12-31 21:45:14 +08:00
# -*- coding: utf-8 -*-
"""
Yuuki_Libs
(c) 2020 Star Inc.
2019-12-31 21:45:14 +08:00
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
2019-08-23 18:12:41 +08:00
from .en import English
2019-08-28 00:45:04 +08:00
from .zh_TW import Traditional_Chinese
2019-08-23 18:12:41 +08:00
2019-12-25 21:35:43 +08:00
2019-08-23 18:12:41 +08:00
class Yuuki_LangSetting:
def __init__(self, default):
self.default = default
self.support = {
2019-09-01 12:26:50 +08:00
"en": English,
"zh-tw": Traditional_Chinese
2019-08-23 18:12:41 +08:00
}
def gettext(self, text, lang=None):
2019-08-25 09:22:44 +08:00
try:
if lang:
return self.support[lang].i18nText[text]
return self.support[self.default].i18nText[text]
except KeyError:
2019-09-07 16:43:11 +08:00
return text + "\n\n{\n\tLanguage Package not work.\n\tPlease inform the Admin of the Yuuki.\n}"