summaryrefslogtreecommitdiffstats
path: root/aurweb/l10n.py
blob: a7c0103e7f2fded1ff031929dd69bfa3c3ac63bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gettext

import aurweb.config


class Translator:
    def __init__(self):
        self._localedir = aurweb.config.get('options', 'localedir')
        self._translator = {}

    def translate(self, s, lang):
        if lang == 'en':
            return s
        if lang not in self._translator:
            self._translator[lang] = gettext.translation("aurweb",
                                                         self._localedir,
                                                         languages=[lang])
        self._translator[lang].install()
        return _(s)