From da55deb61fd0944d833e8e9708357cba38ab1165 Mon Sep 17 00:00:00 2001 From: Einar Hjortdal <102909397+einar-hjortdal@users.noreply.github.com> Date: Sat, 7 Dec 2024 08:46:26 +0100 Subject: [PATCH] Merge pull request #1 from nekoedges/meester feat: Added Russian substitution --- slugify_test.v | 2 ++ substitutions.v | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/slugify_test.v b/slugify_test.v index 21c28c2..d33cf3a 100644 --- a/slugify_test.v +++ b/slugify_test.v @@ -12,6 +12,8 @@ fn test_slugify_make_lang() { assert slugifier.make('Har du røykt sokka dine?') == 'har-du-roeykt-sokka-dine' slugifier.lang = Language.it assert slugifier.make('Un € o un $') == 'un-eur-o-un' + slugifier.lang = Language.ru + assert slugifier.make('любя съешь щипцы вздохнёт мэр кайф жгуч') == 'lyubya-sesh-schiptsi-vzdohnyot-mer-kayf-zhguch' } fn test_max_length() { diff --git a/substitutions.v b/substitutions.v index 16c6da0..d3272e3 100644 --- a/substitutions.v +++ b/substitutions.v @@ -8,6 +8,7 @@ pub enum Language { it nl no + ru } const ( @@ -18,6 +19,7 @@ const ( Language.it: it_sub Language.nl: nl_sub Language.no: no_sub + Language.ru: ru_sub } // en_sub are the default and fallback substitution mappings. // When passing a different language to `make_lang`, any mapping found in the passed language will @@ -97,4 +99,51 @@ const ( 'Ø': 'Oe' 'Å': 'Aa' } + ru_sub = { + 'а': 'a' + 'б': 'b' + 'в': 'v' + 'г': 'g' + 'д': 'd' + 'е': 'e' + 'ё': 'yo' + 'ж': 'zh' + 'з': 'z' + 'дж': 'j' + 'и': 'i' + 'й': 'y' + 'к': 'k' + 'л': 'l' + 'м': 'm' + 'н': 'n' + 'о': 'o' + 'п': 'p' + 'р': 'r' + 'с': 's' + 'т': 't' + 'у': 'u' + 'ф': 'f' + 'х': 'h' + 'ц': 'ts' + 'ч': 'ch' + 'ш': 'sh' + 'щ': 'sch' + 'ъ': '' + 'ы': 'i' + 'ь': '' + 'э': 'e' + 'ю': 'yu' + 'я': 'ya' + '%': 'procent' + '♥': 'serdtse' + '&': 'i' + '@': 'sobaka' + '#': 'reshyotka' + '=': 'ravno' + '~': 'tilda' + '<': 'menshe' + '>': 'bolshe' + '|': 'ili' + '∞': 'beskonechnost' + } )