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


class Translator:
    def __init__(self):
        self._translator = {}

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