music-dl/src/i18n.py

18 lines
502 B
Python
Raw Normal View History

2018-01-24 17:43:35 -06:00
# -*- coding: utf-8 -*-
import os
import gettext
import locale
import sys
2018-03-12 10:02:18 -06:00
import logging
2018-01-24 17:43:35 -06:00
from platform_utils import paths
2018-03-12 10:02:18 -06:00
log = logging.getLogger("i18n")
2018-01-24 17:43:35 -06:00
def setup():
2018-02-27 13:41:18 -06:00
lang = locale.getdefaultlocale()[0]
os.environ["lang"] = lang
2018-03-12 10:02:18 -06:00
log.debug("System detected language: {0}".format(lang,))
if sys.version[0] == "3":
gettext.install("musicdl", localedir=os.path.join(paths.app_path(), "locales"))
else:
gettext.install("musicdl", localedir=os.path.join(paths.app_path(), "locales"), unicode=True)