File: i18n.py

package info (click to toggle)
python-ase 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,192 kB
  • ctags: 8,112
  • sloc: python: 93,375; sh: 99; makefile: 94
file content (21 lines) | stat: -rw-r--r-- 523 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
import os
import sys
import gettext


def enable_localization():
    """Enables localization using gettext.
    
    Translations will be loaded from mo-files when possible.
    """

    domain = 'ag'
    localedir = '%s/po/' % os.path.dirname(__file__)
    
    gettext.bindtextdomain(domain, localedir)
    gettext.textdomain(domain)
    translation = gettext.translation(domain, localedir, fallback=True)
    if sys.version_info[0] == 2:
        translation.install(unicode=True)
    else:
        translation.install()