Ajout des fichiers de traduction et mise à jour de i18n.py

Support du chargement des locales
This commit is contained in:
2013-04-23 14:08:17 +02:00
parent 7cd44d6886
commit e8bc84ab33
4 changed files with 506 additions and 1 deletions

View File

@ -2,5 +2,33 @@
# -*- coding: UTF-8 -*-
import gettext
gettext.translation('tiramisu', fallback=True)
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']
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