From e0ecb03a21cbe6281c027210bc6c318ee752492b Mon Sep 17 00:00:00 2001 From: Yankl-Peretz Blum Date: Mon, 18 Dec 2023 13:55:44 +0200 Subject: [PATCH 1/2] Add Yiddish ruleset and test --- README.md | 2 +- Resources/rules/yiddish.json | 52 ++++++++++++++++++++++++++++++++++++ src/Slugify.php | 1 + tests/SlugifyTest.php | 1 + 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Resources/rules/yiddish.json diff --git a/README.md b/README.md index 6120bce..347921d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Developed by [Florian Eckerstorfer](https://florian.ec) in Vienna, Europe with t ## Features - Removes all special characters from a string. -- Provides custom replacements for Arabic, Austrian, Azerbaijani, Brazilian Portuguese, Bulgarian, Burmese, Chinese, Croatian, Czech, Esperanto, Estonian, Finnish, French, Georgian, German, Greek, Hindi, Hungarian, Italian, Latvian, Lithuanian, Macedonian, Norwegian, Polish, Romanian, Russian, Serbian, Spanish, Swedish, Turkish, Ukrainian and Vietnamese special characters. Instead of removing these characters, Slugify approximates them (e.g., `ae` replaces `ä`). +- Provides custom replacements for Arabic, Austrian, Azerbaijani, Brazilian Portuguese, Bulgarian, Burmese, Chinese, Croatian, Czech, Esperanto, Estonian, Finnish, French, Georgian, German, Greek, Hindi, Hungarian, Italian, Latvian, Lithuanian, Macedonian, Norwegian, Polish, Romanian, Russian, Serbian, Spanish, Swedish, Turkish, Ukrainian, Vietnamese and Yiddish special characters. Instead of removing these characters, Slugify approximates them (e.g., `ae` replaces `ä`). - No external dependencies. - PSR-4 compatible. - Compatible with PHP >= 8. diff --git a/Resources/rules/yiddish.json b/Resources/rules/yiddish.json new file mode 100644 index 0000000..d7c5c7c --- /dev/null +++ b/Resources/rules/yiddish.json @@ -0,0 +1,52 @@ +{ + "יאַ": "ya", + "אַ": "a", + "אָ": "o", + "יאָ": "yo", + "א": "", + "בֿ": "v", + "ב": "b", + "ג": "g", + "ד": "d", + "ה": "h", + "װ": "v", + "וו": "v", + "יױ": "yoy", + "ױ": "oy", + "יוי": "yoy", + "וי": "oy", + "יו": "yu", + "ו": "u", + "ז": "z", + "ח": "kh", + "ט": "t", + "יײַ": "yay", + "ײַ": "ay", + "יי": "ey", + "ײ": "ey", + "יע": "ye", + "ייִ": "yi", + "יִ": "i", + "י": "i", + "כּ": "k", + "כ": "kh", + "ך": "kh", + "ל": "l", + "מ": "m", + "ם": "m", + "נ": "n", + "ן": "n", + "ס": "s", + "ע": "e", + "פּ": "p", + "פֿ": "f", + "פ": "ph", + "צ": "ts", + "ץ": "ts", + "ק": "k", + "ר": "r", + "שֹ": "s", + "ש": "sh", + "תּ": "t", + "ת": "s" +} diff --git a/src/Slugify.php b/src/Slugify.php index 7dce1f6..c9f9e73 100644 --- a/src/Slugify.php +++ b/src/Slugify.php @@ -53,6 +53,7 @@ class Slugify implements SlugifyInterface // Languages are preferred if they appear later, list is ordered by number of // websites in that language // https://en.wikipedia.org/wiki/Languages_used_on_the_Internet#Content_languages_for_websites + 'yiddish', 'armenian', 'azerbaijani', 'burmese', diff --git a/tests/SlugifyTest.php b/tests/SlugifyTest.php index d31cf6a..f95b65b 100644 --- a/tests/SlugifyTest.php +++ b/tests/SlugifyTest.php @@ -260,6 +260,7 @@ public function defaultRuleProvider() [str_repeat('hi🇦🇹', 5000), substr(str_repeat('hi-', 5000), 0, -1)], ['Č Ć Ž Š Đ č ć ž š đ', 'c-c-z-s-d-c-c-z-s-d'], ['Ą Č Ę Ė Į Š Ų Ū Ž ą č ę ė į š ų ū ž', 'a-c-e-e-i-s-u-u-z-a-c-e-e-i-s-u-u-z'], + ['יאַן אַ טאָן יאָ אי רבֿ גיב דו האַװ האַוו יױרן יוירן אַזױ אַזוי יום־כּיפּור חנוכּה יײַכל מײַן בלײך ניי יע ייִדיש פֿליִען צוך סם פ קץ תּורת־אמת', 'yan-a-ton-yo-i-rv-gib-du-hav-hav-yoyrn-yoyrn-azoy-azoy-yum-kipur-khnukh-yaykhl-mayn-bleykh-ney-ye-yidish-flien-tsukh-sm-ph-kts-turs-ms'], ]; } From c0ada2d8c6c88915be855c0aaff811053863d3b1 Mon Sep 17 00:00:00 2001 From: Yankl-Peretz Blum Date: Sat, 23 Dec 2023 21:21:04 +0200 Subject: [PATCH 2/2] Update DefaultRuleProvider.php with Yiddish ruleset --- src/RuleProvider/DefaultRuleProvider.php | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/RuleProvider/DefaultRuleProvider.php b/src/RuleProvider/DefaultRuleProvider.php index a34290c..d50d52b 100644 --- a/src/RuleProvider/DefaultRuleProvider.php +++ b/src/RuleProvider/DefaultRuleProvider.php @@ -10896,6 +10896,59 @@ class DefaultRuleProvider implements RuleProviderInterface 'Ỷ' => 'Y', 'Ỹ' => 'Y', ), + 'yiddish' => + array ( + 'יאַ' => 'ya', + 'אַ' => 'a', + 'אָ' => 'o', + 'יאָ' => 'yo', + 'א' => '', + 'בֿ' => 'v', + 'ב' => 'b', + 'ג' => 'g', + 'ד' => 'd', + 'ה' => 'h', + 'װ' => 'v', + 'וו' => 'v', + 'יױ' => 'yoy', + 'ױ' => 'oy', + 'יוי' => 'yoy', + 'וי' => 'oy', + 'יו' => 'yu', + 'ו' => 'u', + 'ז' => 'z', + 'ח' => 'kh', + 'ט' => 't', + 'יײַ' => 'yay', + 'ײַ' => 'ay', + 'יי' => 'ey', + 'ײ' => 'ey', + 'יע' => 'ye', + 'ייִ' => 'yi', + 'יִ' => 'i', + 'י' => 'i', + 'כּ' => 'k', + 'כ' => 'kh', + 'ך' => 'kh', + 'ל' => 'l', + 'מ' => 'm', + 'ם' => 'm', + 'נ' => 'n', + 'ן' => 'n', + 'ס' => 's', + 'ע' => 'e', + 'פּ' => 'p', + 'פֿ' => 'f', + 'פ' => 'ph', + 'צ' => 'ts', + 'ץ' => 'ts', + 'ק' => 'k', + 'ר' => 'r', + 'שֹ' => 's', + 'ש' => 'sh', + 'תּ' => 't', + 'ת' => 's', + ), )/*INSERT_END*/; /**