-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2017-08-14T17:05:12+02:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/plone.api@03b900e Let ``zope.i18n`` do the language negotiation for our ``translate`` function. Our ``get_current_translation`` does not always give the correct one, especially with combined languages: ``nl-be`` (Belgian/Flemish) should fall back to ``nl`` (Dutch). The correct negotiated language can also differ per translation domain, which we do not account for. ``zope.i18n`` does that better. Fixes plone/plone.api#379. Files changed: M CHANGES.rst M src/plone/api/portal.py Repository: plone.api Branch: refs/heads/master Date: 2017-08-20T22:29:31+02:00 Author: Gil Forcada Codinachs (gforcada) <gil.gnome@gmail.com> Commit: plone/plone.api@88cc536 Merge pull request #382 from plone/issue-379-translate-negotiate Let zope.i18n do language negotiation for our translate function Files changed: M CHANGES.rst M src/plone/api/portal.py
- Loading branch information
Showing
1 changed file
with
120 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,129 @@ | ||
Repository: plone.subrequest | ||
Repository: plone.api | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2017-08-18T18:16:54+02:00 | ||
Author: Johannes Raggam (thet) <thetetet@gmail.com> | ||
Commit: https://github.com/plone/plone.subrequest/commit/a049a4706a076f07da39138ef1fee30f8c0621f7 | ||
Date: 2017-08-14T17:05:12+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> | ||
Commit: https://github.com/plone/plone.api/commit/03b900e6d6cff02bc56baa81339915cc631ae58f | ||
|
||
Revert "Update __init__.py (remove virtual-url-parts from path) (#13)" | ||
Let ``zope.i18n`` do the language negotiation for our ``translate`` function. | ||
|
||
This reverts commit 12abd545e9f165256c83bb048c4e705e288fe752. | ||
It broke subrequest calls in virtual hosted environments. | ||
See: https://github.com/plone/plone.subrequest/issues/14 | ||
And: https://github.com/plone/plone.subrequest/pull/13 | ||
Our ``get_current_translation`` does not always give the correct one, especially with combined languages: | ||
``nl-be`` (Belgian/Flemish) should fall back to ``nl`` (Dutch). | ||
The correct negotiated language can also differ per translation domain, which we do not account for. | ||
``zope.i18n`` does that better. | ||
|
||
Fixes https://github.com/plone/plone.api/issues/379. | ||
|
||
Files changed: | ||
M CHANGES.rst | ||
M src/plone/api/portal.py | ||
|
||
diff --git a/CHANGES.rst b/CHANGES.rst | ||
index be30891..581585e 100644 | ||
--- a/CHANGES.rst | ||
+++ b/CHANGES.rst | ||
@@ -14,7 +14,13 @@ New features: | ||
|
||
Bug fixes: | ||
|
||
-- *add item here* | ||
+- Let ``zope.i18n`` do the language negotiation for our ``translate`` function. | ||
+ Our ``get_current_translation`` does not always give the correct one, especially with combined languages: | ||
+ ``nl-be`` (Belgian/Flemish) should fall back to ``nl`` (Dutch). | ||
+ The correct negotiated language can also differ per translation domain, which we do not account for. | ||
+ ``zope.i18n`` does that better. | ||
+ Fixes `issue 379 <https://github.com/plone/plone.api/issues/379>`_. | ||
+ [maurits] | ||
|
||
|
||
1.8 (2017-08-05) | ||
diff --git a/src/plone/api/portal.py b/src/plone/api/portal.py | ||
index 5dae7b4..81e86cc 100644 | ||
--- a/src/plone/api/portal.py | ||
+++ b/src/plone/api/portal.py | ||
@@ -445,11 +445,12 @@ def translate(msgid, domain='plone', lang=None): | ||
:Example: :ref:`portal_translate_example` | ||
""" | ||
translation_service = get_tool('translation_service') | ||
- if not lang: | ||
- lang = get_current_language() | ||
- | ||
- return translation_service.utranslate( | ||
- msgid=msgid, | ||
- domain=domain, | ||
- target_language=lang, | ||
- ) | ||
+ query = { | ||
+ 'msgid': msgid, | ||
+ 'domain': domain, | ||
+ 'target_language': lang, | ||
+ } | ||
+ if lang is None: | ||
+ # Pass the request, so zope.i18n.translate can negotiate the language. | ||
+ query['context'] = getRequest() | ||
+ return translation_service.utranslate(**query) | ||
|
||
|
||
Repository: plone.api | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2017-08-20T22:29:31+02:00 | ||
Author: Gil Forcada Codinachs (gforcada) <gil.gnome@gmail.com> | ||
Commit: https://github.com/plone/plone.api/commit/88cc536cd82b2dc8c6a91f0e50bfde58d849e92f | ||
|
||
Merge pull request #382 from plone/issue-379-translate-negotiate | ||
|
||
Let zope.i18n do language negotiation for our translate function | ||
|
||
Files changed: | ||
M plone/subrequest/__init__.py | ||
|
||
diff --git a/plone/subrequest/__init__.py b/plone/subrequest/__init__.py | ||
index f95f067..1b46f8f 100644 | ||
--- a/plone/subrequest/__init__.py | ||
+++ b/plone/subrequest/__init__.py | ||
@@ -89,7 +89,6 @@ def subrequest(url, root=None, stdout=None, exception_handler=None): | ||
root_path = normpath( | ||
parent_request['PATH_INFO'] | ||
).rstrip('/')[:-len(path_past_root) or None] | ||
- path = path.replace(vurl_parts[1], '', 1) | ||
if root is None: | ||
path = root_path + path | ||
else: | ||
M CHANGES.rst | ||
M src/plone/api/portal.py | ||
|
||
diff --git a/CHANGES.rst b/CHANGES.rst | ||
index be30891..581585e 100644 | ||
--- a/CHANGES.rst | ||
+++ b/CHANGES.rst | ||
@@ -14,7 +14,13 @@ New features: | ||
|
||
Bug fixes: | ||
|
||
-- *add item here* | ||
+- Let ``zope.i18n`` do the language negotiation for our ``translate`` function. | ||
+ Our ``get_current_translation`` does not always give the correct one, especially with combined languages: | ||
+ ``nl-be`` (Belgian/Flemish) should fall back to ``nl`` (Dutch). | ||
+ The correct negotiated language can also differ per translation domain, which we do not account for. | ||
+ ``zope.i18n`` does that better. | ||
+ Fixes `issue 379 <https://github.com/plone/plone.api/issues/379>`_. | ||
+ [maurits] | ||
|
||
|
||
1.8 (2017-08-05) | ||
diff --git a/src/plone/api/portal.py b/src/plone/api/portal.py | ||
index 5dae7b4..81e86cc 100644 | ||
--- a/src/plone/api/portal.py | ||
+++ b/src/plone/api/portal.py | ||
@@ -445,11 +445,12 @@ def translate(msgid, domain='plone', lang=None): | ||
:Example: :ref:`portal_translate_example` | ||
""" | ||
translation_service = get_tool('translation_service') | ||
- if not lang: | ||
- lang = get_current_language() | ||
- | ||
- return translation_service.utranslate( | ||
- msgid=msgid, | ||
- domain=domain, | ||
- target_language=lang, | ||
- ) | ||
+ query = { | ||
+ 'msgid': msgid, | ||
+ 'domain': domain, | ||
+ 'target_language': lang, | ||
+ } | ||
+ if lang is None: | ||
+ # Pass the request, so zope.i18n.translate can negotiate the language. | ||
+ query['context'] = getRequest() | ||
+ return translation_service.utranslate(**query) | ||
|
||
|