Skip to content

Commit

Permalink
use new request.localizer api when available
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Nov 1, 2016
1 parent d625c45 commit 7124d91
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyramid_jinja2/i18n.py
Expand Up @@ -12,7 +12,11 @@ def __init__(self, domain):

@property
def localizer(self):
return i18n.get_localizer(get_current_request())
request = get_current_request()
try:
return request.localizer
except AttributeError: # pragma: nocover (pyramid < 1.5)
return i18n.get_localizer(request)

def gettext(self, message):
"""Implements jinja.ext.i18n `gettext` function"""
Expand Down

0 comments on commit 7124d91

Please sign in to comment.