Commit 047c9a37 authored by Christophe Combelles's avatar Christophe Combelles

Fix #221025 : adding menu is sorted with translated items

parent c67f4864
...@@ -84,6 +84,7 @@ setup(name='zope.app.container', ...@@ -84,6 +84,7 @@ setup(name='zope.app.container',
'zope.app.broken', 'zope.app.broken',
'zope.copypastemove', 'zope.copypastemove',
'ZODB3', 'ZODB3',
'zope.i18n',
], ],
include_package_data = True, include_package_data = True,
zip_safe = False, zip_safe = False,
......
...@@ -43,7 +43,7 @@ from zope.app.container.interfaces import IAdding, INameChooser ...@@ -43,7 +43,7 @@ from zope.app.container.interfaces import IAdding, INameChooser
from zope.app.container.interfaces import IContainerNamesContainer from zope.app.container.interfaces import IContainerNamesContainer
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.publisher.browser.menu import getMenu from zope.app.publisher.browser.menu import getMenu
from zope.i18n import translate
class Adding(BrowserView): class Adding(BrowserView):
implements(IAdding, IPublishTraverse) implements(IAdding, IPublishTraverse)
...@@ -182,6 +182,9 @@ class Adding(BrowserView): ...@@ -182,6 +182,9 @@ class Adding(BrowserView):
continue continue
elif item['extra']['factory'] != item['action']: elif item['extra']['factory'] != item['action']:
item['has_custom_add_view']=True item['has_custom_add_view']=True
# translate here to have a localized sorting
item['title'] = zope.i18n.translate(item['title'],
context=self.request)
result.append(item) result.append(item)
result.sort(lambda a, b: cmp(a['title'], b['title'])) result.sort(lambda a, b: cmp(a['title'], b['title']))
......
<tal:block define="addingInfo context/@@+/addingInfo|nothing" <tal:block define="addingInfo context/@@+/addingInfo|nothing"
condition="addingInfo" i18n:domain="zope"> condition="addingInfo">
<tal:block repeat="info addingInfo" <tal:block repeat="info addingInfo"
define="namesRequired context/@@+/nameAllowed"> define="namesRequired context/@@+/nameAllowed">
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
tal:attributes=" tal:attributes="
href string:${baseurl}/@@contents.html?type_name=${info/action}; href string:${baseurl}/@@contents.html?type_name=${info/action};
class info/selected" class info/selected"
tal:content="info/title" i18n:translate="">Folder tal:content="info/title">Folder
</a> </a>
<a href="#" <a href="#"
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
tal:attributes=" tal:attributes="
href string:${baseurl}/@@+/action.html?type_name=${info/action}; href string:${baseurl}/@@+/action.html?type_name=${info/action};
class info/selected" class info/selected"
tal:content="info/title" i18n:translate="">Folder tal:content="info/title">Folder
</a> </a>
<a href="#" <a href="#"
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
tal:attributes=" tal:attributes="
href python: info['action'][3:]; href python: info['action'][3:];
class info/selected" class info/selected"
tal:content="info/title" i18n:translate="">Folder tal:content="info/title">Folder
</a> </a>
</div> </div>
</tal:block> </tal:block>
......
...@@ -264,18 +264,18 @@ def test_constraint_driven_addingInfo(): ...@@ -264,18 +264,18 @@ def test_constraint_driven_addingInfo():
>>> len(items) >>> len(items)
1 1
>>> items[0]['title'] >>> items[0]['title']
'item3' u'item3'
>>> adding.menu_id = 'TestMenu' >>> adding.menu_id = 'TestMenu'
>>> items = adding.addingInfo() >>> items = adding.addingInfo()
>>> len(items) >>> len(items)
3 3
>>> items[0]['title'] >>> items[0]['title']
'item1' u'item1'
>>> items[1]['title'] >>> items[1]['title']
'item2' u'item2'
>>> items[2]['title'] >>> items[2]['title']
'item3' u'item3'
""" """
def test_constraint_driven_add(): def test_constraint_driven_add():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment