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>
This commit is contained in:
Lukas Fleischer 2018-05-17 22:05:01 +02:00
parent f3b4c5c6bc
commit f7a57c82bc
4 changed files with 189 additions and 124 deletions

16
aurweb/l10n.py Normal file
View file

@ -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)