Skip to content

Instantly share code, notes, and snippets.

@ozten
Created April 14, 2011 18:05
Show Gist options
  • Save ozten/920088 to your computer and use it in GitHub Desktop.
Save ozten/920088 to your computer and use it in GitHub Desktop.
# _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