diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2018-05-17 22:05:01 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2018-05-17 22:58:54 +0200 |
commit | f7a57c82bceeeae33b3244ba33b4844f5b692298 (patch) | |
tree | 7a9fe06bdc0cb97dc122e99cdba0fc949916c66c /aurweb/l10n.py | |
parent | f3b4c5c6bc6cd1f7320505ca725c46c78e1362f3 (diff) | |
download | aur-f7a57c82bceeeae33b3244ba33b4844f5b692298.tar.gz aur-f7a57c82bceeeae33b3244ba33b4844f5b692298.tar.xz |
Localize notification emails
Add support for translating notification emails and send localized
notifications, based on the user's language preferences. Also, update
the translations Makefile to add strings from the notification script
to the message catalog.
Implements FS#31850.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'aurweb/l10n.py')
-rw-r--r-- | aurweb/l10n.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/aurweb/l10n.py b/aurweb/l10n.py new file mode 100644 index 00000000..e58e3fe2 --- /dev/null +++ b/aurweb/l10n.py @@ -0,0 +1,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) |