diff --git a/README.md b/README.md index db6c78a..64ea925 100644 --- a/README.md +++ b/README.md @@ -810,13 +810,14 @@ random order. s('fòôbàř')->shuffle(); // 'àôřbòf' ``` -##### slugify([, string $replacement = '-' ]) +##### slugify([, string $replacement = '-' [, string $language = 'en']]) Converts the string into an URL slug. This includes replacing non-ASCII characters with their closest ASCII equivalents, removing remaining non-ASCII and non-alphanumeric characters, and replacing whitespace with $replacement. The replacement defaults to a single dash, and the string -is also converted to lowercase. +is also converted to lowercase. The language of the source string can +also be supplied for language-specific transliteration. ```php s('Using strings like fòô bàř')->slugify(); // 'using-strings-like-foo-bar' diff --git a/src/Stringy.php b/src/Stringy.php index a46a483..125191b 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -1157,14 +1157,16 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess * characters with their closest ASCII equivalents, removing remaining * non-ASCII and non-alphanumeric characters, and replacing whitespace with * $replacement. The replacement defaults to a single dash, and the string - * is also converted to lowercase. + * is also converted to lowercase. The language of the source string can + * also be supplied for language-specific transliteration. * * @param string $replacement The string used to replace whitespace + * @param string $language Language of the source string * @return static Object whose $str has been converted to an URL slug */ - public function slugify($replacement = '-') + public function slugify($replacement = '-', $language = 'en') { - $stringy = $this->toAscii(); + $stringy = $this->toAscii($language); $stringy->str = str_replace('@', $replacement, $stringy); $quotedReplacement = preg_quote($replacement);