2020-07-16 12:46:23 +00:00
|
|
|
import gettext, sys, logging
|
|
|
|
from src.configloader import settings
|
|
|
|
logger = logging.getLogger("rcgcdw.i18n")
|
|
|
|
|
|
|
|
# Setup translation
|
|
|
|
|
|
|
|
try:
|
2020-08-03 13:27:24 +00:00
|
|
|
if settings["lang"] != "en":
|
2020-08-08 01:23:01 +00:00
|
|
|
rcgcdw = gettext.translation('rcgcdw', localedir='locale', languages=[settings["lang"]])
|
|
|
|
discussion_formatters = gettext.translation('discussion_formatters', localedir='locale', languages=[settings["lang"]])
|
|
|
|
rc = gettext.translation('rc', localedir='locale', languages=[settings["lang"]])
|
|
|
|
rc_formatters = gettext.translation('rc_formatters', localedir='locale', languages=[settings["lang"]])
|
2020-08-03 13:27:24 +00:00
|
|
|
misc = gettext.translation('misc', localedir='locale', languages=[settings["lang"]])
|
2020-11-16 22:09:34 +00:00
|
|
|
redaction = gettext.translation('redaction', localedir='locale', languages=[settings["lang"]])
|
2020-08-03 13:27:24 +00:00
|
|
|
else:
|
2020-11-16 22:09:34 +00:00
|
|
|
rcgcdw, discussion_formatters, rc, rc_formatters, misc, redaction = gettext.NullTranslations(), gettext.NullTranslations(), gettext.NullTranslations(), gettext.NullTranslations(), gettext.NullTranslations(), gettext.NullTranslations()
|
2020-07-16 12:46:23 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
logger.critical("No language files have been found. Make sure locale folder is located in the directory.")
|
|
|
|
sys.exit(1)
|