diff options
| author | Val Neekman <val@neekware.com> | 2019-10-10 18:12:07 -0400 |
|---|---|---|
| committer | Val Neekman <val@neekware.com> | 2019-10-10 18:12:07 -0400 |
| commit | 33bf07efc82c00b811df02bca8c5862f95db3294 (patch) | |
| tree | 5ce14d61e8f5faff7e5238c6292723cc3ad9d05d /slugify/special.py | |
| parent | 67c16a409063578d38bf69ee345254e67b237206 (diff) | |
| download | python-slugify-3.0.5.tar.gz | |
add special pre translation file, more unit test, updated readme3.0.5
Diffstat (limited to 'slugify/special.py')
| -rw-r--r-- | slugify/special.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/slugify/special.py b/slugify/special.py new file mode 100644 index 0000000..767541a --- /dev/null +++ b/slugify/special.py @@ -0,0 +1,44 @@ +def add_uppercase_char(char_list): + """ Given a replacement char list, this adds uppercase chars to the list """ + + for item in char_list: + char, xlate = item + upper_dict = char.upper(), xlate.capitalize() + if upper_dict not in char_list and char != upper_dict[0]: + char_list.insert(0, upper_dict) + return char_list + + +# Language specific pre translations +# Source awesome-slugify + +_CYRILLIC = [ # package defaults: + (u'ё', u'e'), # io / yo + (u'я', u'ya'), # ia + (u'х', u'h'), # kh + (u'у', u'y'), # u + (u'щ', u'sch'), # shch + (u'ю', u'u'), # iu / yu +] +CYRILLIC = add_uppercase_char(_CYRILLIC) + +_GERMAN = [ # package defaults: + (u'ä', u'ae'), # a + (u'ö', u'oe'), # o + (u'ü', u'ue'), # u +] +GERMAN = add_uppercase_char(_GERMAN) + +_GREEK = [ # package defaults: + (u'χ', u'ch'), # kh + (u'Ξ', u'X'), # Ks + (u'ϒ', u'Y'), # U + (u'υ', u'y'), # u + (u'ύ', u'y'), + (u'ϋ', u'y'), + (u'ΰ', u'y'), +] +GREEK = add_uppercase_char(_GREEK) + +# Pre translations +PRE_TRANSLATIONS = CYRILLIC + GERMAN + GREEK |
