aurweb.l10n: Translate without side effects

Message ID 20200609182522.GA225025@tsubame.mg0.fr
State New
Headers show
Series aurweb.l10n: Translate without side effects | expand

Commit Message

Frédéric Mangano-Tarumi June 9, 2020, 6:25 p.m. UTC
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.
---
 aurweb/l10n.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Lukas Fleischer June 10, 2020, 2:59 a.m. UTC | #1
On Tue, 09 Jun 2020 at 14:25:22, Frédéric Mangano-Tarumi wrote:
> The install method in Python\u2019s gettext API aliases the translator\u2019s
> gettext method to an application-global _(). We don\u2019t use that anywhere,
> and it\u2019s clear from aurweb\u2019s Translator interface that we want to
> translate a piece of text without affecting any global namespace.
> ---
>  aurweb/l10n.py | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Merged into pu. Will review your other patches later this week. Thanks!

Patch

diff --git a/aurweb/l10n.py b/aurweb/l10n.py
index 492200b3..51b56abb 100644
--- a/aurweb/l10n.py
+++ b/aurweb/l10n.py
@@ -15,5 +15,4 @@  class Translator:
             self._translator[lang] = gettext.translation("aurweb",
                                                          self._localedir,
                                                          languages=[lang])
-        self._translator[lang].install()
-        return _(s)  # _ is not defined, what is this?  # noqa: F821
+        return self._translator[lang].gettext(s)