35 lines
746 B
Python
35 lines
746 B
Python
#!/usr/bin/env python
|
|
# -*- coding: UTF-8 -*-
|
|
"internationalisation utilities"
|
|
import gettext
|
|
import os
|
|
import sys
|
|
import locale
|
|
|
|
# Application Name
|
|
APP_NAME = 'tiramisu'
|
|
|
|
# Traduction dir
|
|
APP_DIR = os.path.join(sys.prefix, 'share')
|
|
LOCALE_DIR = os.path.join(APP_DIR, 'locale')
|
|
|
|
# Default Lanugage
|
|
DEFAULT_LANG = os.environ.get('LANG', '').split(':')
|
|
DEFAULT_LANG += ['en_US']
|
|
|
|
languages = []
|
|
lc, encoding = locale.getdefaultlocale()
|
|
if lc:
|
|
languages = [lc]
|
|
|
|
languages += DEFAULT_LANG
|
|
mo_location = LOCALE_DIR
|
|
|
|
gettext.install(True, localedir=None, unicode=1)
|
|
gettext.find(APP_NAME, mo_location)
|
|
gettext.textdomain(APP_NAME)
|
|
gettext.bind_textdomain_codeset(APP_NAME, "UTF-8")
|
|
gettext.translation(APP_NAME, fallback=True)
|
|
|
|
_ = gettext.gettext
|