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")
|
2020-12-21 18:21:30 +00:00
|
|
|
supported_languages = ('de', 'hi', 'pl', 'pt-br', 'ru', 'zh-hans', 'zh-hant')
|
2020-08-09 23:57:14 +00:00
|
|
|
translated_files = ('wiki', 'misc', 'discord', 'rc_formatters', 'discussion_formatters')
|
2020-07-11 15:54:08 +00:00
|
|
|
|
|
|
|
try:
|
2020-08-09 23:57:14 +00:00
|
|
|
langs = defaultdict(dict)
|
|
|
|
for lang in supported_languages:
|
|
|
|
for file in translated_files:
|
|
|
|
langs[lang][file] = gettext.translation(file, localedir='locale', languages=[lang])
|
|
|
|
for file in translated_files:
|
|
|
|
langs["en"][file] = gettext.NullTranslations()
|
2020-07-11 15:54:08 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
logger.critical("No language files have been found. Make sure locale folder is located in the directory.")
|
|
|
|
sys.exit(1)
|