Skip to content

Commit

Permalink
Do not rely on LANGUAGE key on request to skip negotiation; the value…
Browse files Browse the repository at this point in the history
… is implementation-specific, and not always a valid 'target_language' string.
  • Loading branch information
malthe committed Apr 24, 2012
1 parent ab85dec commit 7a59db3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

In next release ...

Bugfixes:

- Do not rely on the "LANGUAGE" request key to skip language
negotiation. Instead, we assume that negotiation is cheap (and
probably cached).

2.2.1 (2012-02-15)
~~~~~~~~~~~~~~~~~~

Expand Down
11 changes: 4 additions & 7 deletions src/z3c/pt/pagetemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,10 @@ def render(self, target_language=None, **context):
request = context.setdefault('request', None)

if target_language is None:
if hasattr(request, "get"):
target_language = request.get("LANGUAGE", None)
if target_language is None:
try:
target_language = i18n.negotiate(request)
except:
target_language = None
try:
target_language = i18n.negotiate(request)
except:
target_language = None

context['target_language'] = target_language

Expand Down

0 comments on commit 7a59db3

Please sign in to comment.