mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
The install method in Python’s gettext API aliases the translator’s gettext method to an application-global _(). We don’t use that anywhere, and it’s clear from aurweb’s Translator interface that we want to translate a piece of text without affecting any global namespace. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
18 lines
566 B
Python
18 lines
566 B
Python
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])
|
|
return self._translator[lang].gettext(s)
|