diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-04-24 16:39:59 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-04-24 16:40:30 -0500 |
commit | c47be4b8bad385772c9926d2219f347628f60045 (patch) | |
tree | b1e97a425fe1219f5cd7114a99e4e6666043861d /mediagoblin/tools | |
parent | a789b713f534156d923cf6cc9070559ac8b6c616 (diff) | |
download | mediagoblin-c47be4b8bad385772c9926d2219f347628f60045.tar.lz mediagoblin-c47be4b8bad385772c9926d2219f347628f60045.tar.xz mediagoblin-c47be4b8bad385772c9926d2219f347628f60045.zip |
Adding ReallyLazyProxy, a proxy that does what we expect :)
Diffstat (limited to 'mediagoblin/tools')
-rw-r--r-- | mediagoblin/tools/translate.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mediagoblin/tools/translate.py b/mediagoblin/tools/translate.py index 47038267..00677863 100644 --- a/mediagoblin/tools/translate.py +++ b/mediagoblin/tools/translate.py @@ -42,6 +42,15 @@ def set_available_locales(): AVAILABLE_LOCALES = locales +class ReallyLazyProxy(LazyProxy): + """ + Like LazyProxy, except that it doesn't cache the value ;) + """ + @property + def value(self): + return self._func(*self._args, **self._kwargs) + + def locale_to_lower_upper(locale): """ Take a locale, regardless of style, and format it like "en_US" @@ -127,7 +136,6 @@ def pass_to_ugettext(*args, **kwargs): return mg_globals.thread_scope.translations.ugettext( *args, **kwargs) - def pass_to_ungettext(*args, **kwargs): """ Pass a translation on to the appropriate ungettext method. @@ -138,6 +146,7 @@ def pass_to_ungettext(*args, **kwargs): return mg_globals.thread_scope.translations.ungettext( *args, **kwargs) + def lazy_pass_to_ugettext(*args, **kwargs): """ Lazily pass to ugettext. @@ -149,7 +158,7 @@ def lazy_pass_to_ugettext(*args, **kwargs): you would want to use the lazy version for _. """ - return LazyProxy(pass_to_ugettext, *args, **kwargs) + return ReallyLazyProxy(pass_to_ugettext, *args, **kwargs) def pass_to_ngettext(*args, **kwargs): @@ -171,7 +180,7 @@ def lazy_pass_to_ngettext(*args, **kwargs): level but you need it to not translate until the time that it's used as a string. """ - return LazyProxy(pass_to_ngettext, *args, **kwargs) + return ReallyLazyProxy(pass_to_ngettext, *args, **kwargs) def lazy_pass_to_ungettext(*args, **kwargs): """ @@ -181,7 +190,7 @@ def lazy_pass_to_ungettext(*args, **kwargs): 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) + return ReallyLazyProxy(pass_to_ungettext, *args, **kwargs) def fake_ugettext_passthrough(string): |