Skip to content

Commit

Permalink
Merge pull request #336 from yankl/yiddish
Browse files Browse the repository at this point in the history
Add Yiddish language ruleset
  • Loading branch information
florianeckerstorfer authored Dec 25, 2023
2 parents af14505 + c0ada2d commit 8672df7
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
52 changes: 52 additions & 0 deletions Resources/rules/yiddish.json
Original file line number Diff line number Diff line change
@@ -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"
}
53 changes: 53 additions & 0 deletions src/RuleProvider/DefaultRuleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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*/;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Slugify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions tests/SlugifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
];
}

Expand Down

0 comments on commit 8672df7

Please sign in to comment.