]> git.ipfire.org Git - pakfire.git/blob - pakfire/i18n.py
Enhance translation code to support plural translations.
[pakfire.git] / pakfire / i18n.py
1 #!/usr/bin/python
2
3 """
4 The translation process of all strings is done in here.
5 """
6
7 import gettext
8
9 """
10 A function that returnes the same string.
11 """
12 N_ = lambda x: x
13
14 def _(singular, plural=None, n=None):
15 """
16 A function that returnes the translation of a string if available.
17
18 The language is taken from the system environment.
19 """
20 if not plural is None:
21 assert n is not None
22 return gettext.ldngettext("pakfire", singular, plural, n)
23
24 return gettext.ldgettext("pakfire", singular)