summaryrefslogtreecommitdiff
path: root/slugify
diff options
context:
space:
mode:
authorVal Neekman <val@neekware.com>2019-10-10 18:12:07 -0400
committerVal Neekman <val@neekware.com>2019-10-10 18:12:07 -0400
commit33bf07efc82c00b811df02bca8c5862f95db3294 (patch)
tree5ce14d61e8f5faff7e5238c6292723cc3ad9d05d /slugify
parent67c16a409063578d38bf69ee345254e67b237206 (diff)
downloadpython-slugify-33bf07efc82c00b811df02bca8c5862f95db3294.tar.gz
add special pre translation file, more unit test, updated readme3.0.5
Diffstat (limited to 'slugify')
-rw-r--r--slugify/__init__.py3
-rw-r--r--slugify/special.py44
2 files changed, 46 insertions, 1 deletions
diff --git a/slugify/__init__.py b/slugify/__init__.py
index 52a07b4..0c86a4c 100644
--- a/slugify/__init__.py
+++ b/slugify/__init__.py
@@ -1,6 +1,7 @@
+from .special import *
from .slugify import *
__author__ = 'Val Neekman @ Neekware Inc. [@vneekman]'
__description__ = 'A Python slugify application that also handles Unicode'
-__version__ = '3.0.4'
+__version__ = '3.0.5'
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