Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ef4bdd

Browse files
committed
Add support to slugify
1 parent d9cee68 commit 8ef4bdd

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,13 +810,14 @@ random order.
810810
s('fòôbàř')->shuffle(); // 'àôřbòf'
811811
```
812812

813-
##### slugify([, string $replacement = '-' ])
813+
##### slugify([, string $replacement = '-' [, string $language = 'en']])
814814

815815
Converts the string into an URL slug. This includes replacing non-ASCII
816816
characters with their closest ASCII equivalents, removing remaining
817817
non-ASCII and non-alphanumeric characters, and replacing whitespace with
818818
$replacement. The replacement defaults to a single dash, and the string
819-
is also converted to lowercase.
819+
is also converted to lowercase. The language of the source string can
820+
also be supplied for language-specific transliteration.
820821

821822
```php
822823
s('Using strings like fòô bàř')->slugify(); // 'using-strings-like-foo-bar'

src/Stringy.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,14 +1157,16 @@ public function shuffle()
11571157
* characters with their closest ASCII equivalents, removing remaining
11581158
* non-ASCII and non-alphanumeric characters, and replacing whitespace with
11591159
* $replacement. The replacement defaults to a single dash, and the string
1160-
* is also converted to lowercase.
1160+
* is also converted to lowercase. The language of the source string can
1161+
* also be supplied for language-specific transliteration.
11611162
*
11621163
* @param string $replacement The string used to replace whitespace
1164+
* @param string $language Language of the source string
11631165
* @return static Object whose $str has been converted to an URL slug
11641166
*/
1165-
public function slugify($replacement = '-')
1167+
public function slugify($replacement = '-', $language = 'en')
11661168
{
1167-
$stringy = $this->toAscii();
1169+
$stringy = $this->toAscii($language);
11681170

11691171
$stringy->str = str_replace('@', $replacement, $stringy);
11701172
$quotedReplacement = preg_quote($replacement);

0 commit comments

Comments
 (0)