Created
April 14, 2011 18:05
-
-
Save ozten/920088 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# _lazy is just like _() except safe for multi-threaded code | |
# top level variables aren't thread safe and you can end up with | |
# en-US for part of the execution and fr for the next piece :/ | |
from tower import ugettext as _ | |
from tower import ugettext_lazy as _lazy | |
questions = {'slug1': _lazy(u'Which kind of Super hero are You?', | |
'slug2': _lazy(u'Charlie Sheen would say you are:', | |
... | |
} | |
# or | |
def question(slug): | |
questions = {'slug1': _(u'Which kind of Super hero are You?', | |
'slug2': _(u'Charlie Sheen would say you are:', | |
... | |
} | |
return questions[slug] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment