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',
'zope.app.broken',
'zope.copypastemove',
'ZODB3',
'zope.i18n',
],
include_package_data = True,
zip_safe = False,
......
......@@ -43,7 +43,7 @@ from zope.app.container.interfaces import IAdding, INameChooser
from zope.app.container.interfaces import IContainerNamesContainer
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.publisher.browser.menu import getMenu
from zope.i18n import translate
class Adding(BrowserView):
implements(IAdding, IPublishTraverse)
......@@ -182,6 +182,9 @@ class Adding(BrowserView):
continue
elif item['extra']['factory'] != item['action']:
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.sort(lambda a, b: cmp(a['title'], b['title']))
......
<tal:block define="addingInfo context/@@+/addingInfo|nothing"
condition="addingInfo" i18n:domain="zope">
condition="addingInfo">
<tal:block repeat="info addingInfo"
define="namesRequired context/@@+/nameAllowed">
......@@ -15,7 +15,7 @@
tal:attributes="
href string:${baseurl}/@@contents.html?type_name=${info/action};
class info/selected"
tal:content="info/title" i18n:translate="">Folder
tal:content="info/title">Folder
</a>
<a href="#"
......@@ -25,7 +25,7 @@
tal:attributes="
href string:${baseurl}/@@+/action.html?type_name=${info/action};
class info/selected"
tal:content="info/title" i18n:translate="">Folder
tal:content="info/title">Folder
</a>
<a href="#"
......@@ -34,7 +34,7 @@
tal:attributes="
href python: info['action'][3:];
class info/selected"
tal:content="info/title" i18n:translate="">Folder
tal:content="info/title">Folder
</a>
</div>
</tal:block>
......
......@@ -264,18 +264,18 @@ def test_constraint_driven_addingInfo():
>>> len(items)
1
>>> items[0]['title']
'item3'
u'item3'
>>> adding.menu_id = 'TestMenu'
>>> items = adding.addingInfo()
>>> len(items)
3
>>> items[0]['title']
'item1'
u'item1'
>>> items[1]['title']
'item2'
u'item2'
>>> items[2]['title']
'item3'
u'item3'
"""
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