aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools/translate.py
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/tools/translate.py')
-rw-r--r--mediagoblin/tools/translate.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/mediagoblin/tools/translate.py b/mediagoblin/tools/translate.py
index 1d37c4de..4acafac7 100644
--- a/mediagoblin/tools/translate.py
+++ b/mediagoblin/tools/translate.py
@@ -123,6 +123,16 @@ def pass_to_ugettext(*args, **kwargs):
*args, **kwargs)
+def pass_to_ungettext(*args, **kwargs):
+ """
+ Pass a translation on to the appropriate ungettext method.
+
+ 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)
+
def lazy_pass_to_ugettext(*args, **kwargs):
"""
Lazily pass to ugettext.
@@ -158,6 +168,16 @@ def lazy_pass_to_ngettext(*args, **kwargs):
"""
return LazyProxy(pass_to_ngettext, *args, **kwargs)
+def lazy_pass_to_ungettext(*args, **kwargs):
+ """
+ Lazily pass to ungettext.
+
+ This is useful if you have to define a translation on a module
+ level but you need it to not translate until the time that it's
+ used as a string.
+ """
+ return LazyProxy(pass_to_ungettext, *args, **kwargs)
+
def fake_ugettext_passthrough(string):
"""