Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented sorting of ReallyUserFriendlyTypes using unidecode #93

Merged
merged 8 commits into from
Jul 24, 2024
Merged
2 changes: 2 additions & 0 deletions news/3985.chore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Implemented pyICU for sorting of ReallyUserFriendlyTypes
[rohnsha0]
12 changes: 8 additions & 4 deletions plone/app/vocabularies/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary
from unidecode import unidecode


def getAllowedContentTypes(context):
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()
ReallyUserFriendlyTypesVocabularyFactory = ReallyUserFriendlyTypesVocabulary()
Loading