Add ugettext and ungettext helpers to mediagoblin._compat.
This commit is contained in:
parent
fd19da346b
commit
a80c74bbcc
@ -2,9 +2,15 @@ import sys
|
|||||||
|
|
||||||
from six import PY3, iteritems
|
from six import PY3, iteritems
|
||||||
|
|
||||||
|
from mediagoblin import mg_globals
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from urllib import parse as urlparse
|
from urllib import parse as urlparse
|
||||||
|
ugettext = mg_globals.thread_scope.translations.gettext
|
||||||
|
ungettext = mg_globals.thread_scope.translations.ngettext
|
||||||
else:
|
else:
|
||||||
from email.MIMEText import MIMEText
|
from email.MIMEText import MIMEText
|
||||||
import urlparse
|
import urlparse
|
||||||
|
ugettext = mg_globals.thread_scope.translations.ugettext
|
||||||
|
ungettext = mg_globals.thread_scope.translations.ungettext
|
||||||
|
@ -33,6 +33,7 @@ from mediagoblin.tools.pluginapi import get_hook_templates, hook_transform
|
|||||||
from mediagoblin.tools.timesince import timesince
|
from mediagoblin.tools.timesince import timesince
|
||||||
from mediagoblin.meddleware.csrf import render_csrf_form_token
|
from mediagoblin.meddleware.csrf import render_csrf_form_token
|
||||||
|
|
||||||
|
from mediagoblin._compat import ugettext, ungettext
|
||||||
|
|
||||||
SETUP_JINJA_ENVS = {}
|
SETUP_JINJA_ENVS = {}
|
||||||
|
|
||||||
@ -66,9 +67,7 @@ def get_jinja_env(template_loader, locale):
|
|||||||
'jinja2.ext.i18n', 'jinja2.ext.autoescape',
|
'jinja2.ext.i18n', 'jinja2.ext.autoescape',
|
||||||
TemplateHookExtension] + local_exts)
|
TemplateHookExtension] + local_exts)
|
||||||
|
|
||||||
template_env.install_gettext_callables(
|
template_env.install_gettext_callables(ugettext, ungettext)
|
||||||
mg_globals.thread_scope.translations.ugettext,
|
|
||||||
mg_globals.thread_scope.translations.ungettext)
|
|
||||||
|
|
||||||
# All templates will know how to ...
|
# All templates will know how to ...
|
||||||
# ... fetch all waiting messages and remove them from the queue
|
# ... fetch all waiting messages and remove them from the queue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user