theme: apply collation when sorting themes (#77217)
gitea/hobo/pipeline/head This commit looks good Details

It's not perfect but enough to have a usable sorting order.
This commit is contained in:
Benjamin Dauvergne 2023-05-03 09:09:46 +02:00
parent f805a4ab31
commit cc15770e78
1 changed files with 7 additions and 1 deletions

View File

@ -16,6 +16,7 @@
import json
import os
import unicodedata
from django.conf import settings
@ -38,7 +39,12 @@ def get_themes():
if not 'module' in theme:
theme['module'] = dirname
themes.append(theme)
themes.sort(key=lambda x: x.get('label'))
def key_function(theme):
label = theme.get('label')
return unicodedata.normalize('NFKD', label.upper()).encode('ascii', 'ignore').decode()
themes.sort(key=key_function)
return themes