File: i18n.py

package info (click to toggle)
gaphor 0.13.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,692 kB
  • ctags: 2,971
  • sloc: python: 19,981; xml: 247; makefile: 54; sh: 40
file content (27 lines) | stat: -rw-r--r-- 674 bytes parent folder | download | duplicates (2)
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
# vim:sw=4:et
"""
Internationalization (i18n) support for Gaphor.

Here the _() function is defined that is used to translate text into
your native language.
"""

__all__ = [ '_' ]

import os

import gettext
import pkg_resources

# default locale dir = site-base/gaphor/data/locale/<lang>/LC_MESSAGES/gaphor.mo
localedir = os.path.join(pkg_resources.get_distribution('gaphor').location, \
                         'gaphor', 'data', 'locale')

try:
    catalog = gettext.Catalog('gaphor', localedir=localedir)
    #log.info('catalog = %s' % catalog.info())
    _ = catalog.gettext
except IOError, e:
    #log.error('Could not load locale catalog', e)
    def _(s): return s