RcGcDb/src/i18n.py

18 lines
579 B
Python
Raw Normal View History

2020-07-11 15:54:08 +00:00
import sys, logging, gettext
2020-08-09 23:57:14 +00:00
from collections import defaultdict
2020-07-11 15:54:08 +00:00
logger = logging.getLogger("rcgcdb.i18n")
2022-11-25 16:24:44 +00:00
supported_languages = ('de', 'hi', 'pl', 'pt-br', 'ru', 'zh-hans', 'zh-hant', 'es')
translated_files = ('wiki', 'misc', 'formatters')
2020-07-11 15:54:08 +00:00
2022-11-25 16:24:44 +00:00
langs = defaultdict(dict)
for lang in supported_languages:
2020-08-09 23:57:14 +00:00
for file in translated_files:
try:
langs[lang][file] = gettext.translation(file, localedir='locale', languages=[lang])
except FileNotFoundError:
logger.error(f"Language: {lang}")
raise
2022-11-25 16:24:44 +00:00
for file in translated_files:
langs["en"][file] = gettext.NullTranslations()