File: __init__.py

package info (click to toggle)
python-csb43 0.9.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 560 kB
  • sloc: python: 6,233; sh: 9; makefile: 6
file content (43 lines) | stat: -rw-r--r-- 869 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-

import os
import locale
import gettext

import pkg_resources

# Change this variable to your app name!
#  The translation files will be under
#  @LOCALE_DIR@/@LANGUAGE@/LC_MESSAGES/@DOMAIN_NAME@.mo
DOMAIN_NAME = "messages"

LOCALE_DIR = pkg_resources.resource_filename(__name__, '')

DEFAULT_LANGUAGES = os.environ.get('LANG', '').split(':')
DEFAULT_LANGUAGES += ['en']

languages = []
try:
    lc, encoding = locale.getdefaultlocale()
except ValueError:
    lc, encoding = None, None
if lc:
    languages.append(lc)

languages += DEFAULT_LANGUAGES
mo_location = LOCALE_DIR

gettext.install(DOMAIN_NAME, localedir=None)

gettext.textdomain(DOMAIN_NAME)

#gettext.bind_textdomain_codeset(DOMAIN_NAME, "UTF-8")

language = gettext.translation(
    DOMAIN_NAME,
    mo_location,
    languages=languages,
    fallback=True
)

tr = language.gettext