From f9a7201c32a42f31ac7c0c8568e80c8fbf5aec32 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Mon, 2 Jun 2014 22:25:27 +0300 Subject: [PATCH] Use mediagoblin._compat.{ugettext, ungettext} on Python 3. --- mediagoblin/_compat.py | 1 + mediagoblin/tools/translate.py | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mediagoblin/_compat.py b/mediagoblin/_compat.py index fd6172fd..c38e0727 100644 --- a/mediagoblin/_compat.py +++ b/mediagoblin/_compat.py @@ -7,6 +7,7 @@ from mediagoblin import mg_globals if PY3: from email.mime.text import MIMEText from urllib import parse as urlparse + # TODO(berker): Rename to gettext and ungettext instead? ugettext = mg_globals.thread_scope.translations.gettext ungettext = mg_globals.thread_scope.translations.ngettext else: diff --git a/mediagoblin/tools/translate.py b/mediagoblin/tools/translate.py index 257bd791..e6df612d 100644 --- a/mediagoblin/tools/translate.py +++ b/mediagoblin/tools/translate.py @@ -22,6 +22,7 @@ from babel import localedata from babel.support import LazyProxy from mediagoblin import mg_globals +from mediagoblin._compat import ugettext, ungettext ################### # Translation tools @@ -146,8 +147,7 @@ def pass_to_ugettext(*args, **kwargs): The reason we can't have a global ugettext method is because mg_globals gets swapped out by the application per-request. """ - return mg_globals.thread_scope.translations.ugettext( - *args, **kwargs) + return ugettext(*args, **kwargs) def pass_to_ungettext(*args, **kwargs): """ @@ -156,8 +156,7 @@ def pass_to_ungettext(*args, **kwargs): The reason we can't have a global ugettext method is because mg_globals gets swapped out by the application per-request. """ - return mg_globals.thread_scope.translations.ungettext( - *args, **kwargs) + return ungettext(*args, **kwargs) def lazy_pass_to_ugettext(*args, **kwargs): -- 2.25.1