Skip to content

Commit

Permalink
Merge pull request #93 from plone/sorting-ReallyUserFriendlyTypes-usi…
Browse files Browse the repository at this point in the history
…ng-pyicu

Implemented sorting of ReallyUserFriendlyTypes using `unidecode`
  • Loading branch information
rohnsha0 authored Jul 24, 2024
2 parents a05b0cc + 82bb290 commit 1da12d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions news/3985.chore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Implemented sorting of ReallyUserFriendlyTypes using `unidecode`.
[rohnsha0]
10 changes: 7 additions & 3 deletions plone/app/vocabularies/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from Acquisition import aq_get
from plone.app.vocabularies import PermissiveVocabulary
from Products.CMFCore.utils import getToolByName
from unidecode import unidecode
from zope.component.hooks import getSite
from zope.deprecation import deprecate
from zope.i18n import translate
Expand Down Expand Up @@ -298,9 +299,12 @@ def __call__(self, context):
for t in ttool.listContentTypes()
if t not in BAD_TYPES
]
items.sort()
items = [SimpleTerm(i[1], i[1], i[0]) for i in items]
return PermissiveVocabulary(items)

# Sort items based on the translated title using unidecode
items.sort(key=lambda x: unidecode(x[0]).lower())

terms = [SimpleTerm(i[1], i[1], i[0]) for i in items]
return PermissiveVocabulary(terms)


ReallyUserFriendlyTypesVocabularyFactory = ReallyUserFriendlyTypesVocabulary()
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"plone.uuid",
"pytz",
"setuptools",
"unidecode",
"z3c.formwidget.query",
"zope.browser",
"zope.globalrequest",
Expand Down

0 comments on commit 1da12d2

Please sign in to comment.