Skip to content
Snippets Groups Projects
Commit 55024222 authored by ynerant's avatar ynerant
Browse files

🎨 Normalize - to _ since these characters are used a lot

parent bac14521
No related branches found
No related tags found
1 merge request!104Beta
...@@ -247,7 +247,8 @@ class Alias(models.Model): ...@@ -247,7 +247,8 @@ class Alias(models.Model):
Normalizes a string: removes most diacritics, does casefolding and ignore non-ASCII characters Normalizes a string: removes most diacritics, does casefolding and ignore non-ASCII characters
""" """
return ''.join( return ''.join(
char for char in unicodedata.normalize('NFKD', string.casefold().replace('æ', 'ae').replace('œ', 'oe')) char for char in unicodedata.normalize('NFKD', string.casefold().replace('æ', 'ae')
.replace('œ', 'oe').replace('-', '_'))
if all(not unicodedata.category(char).startswith(cat) if all(not unicodedata.category(char).startswith(cat)
for cat in {'M', 'P', 'Z', 'C'})).casefold().encode('ascii', 'ignore').decode('ascii') for cat in {'M', 'P', 'Z', 'C'})).casefold().encode('ascii', 'ignore').decode('ascii')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment