Skip to content

Commit 783b395

Browse files
authored
[String] Feature 39178
Documentation update for [String] Feature 39178 "AsciiSlugger's symbolsMap should apply to all locales for a language".
1 parent edbb23a commit 783b395

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/string.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ that only includes safe ASCII characters::
477477
$slug = $slugger->slug('10% or 5€');
478478
// $slug = '10-percent-or-5-euro'
479479

480+
// if there is no symbols map for your locale (e.g. 'en_GB') then the parent locale's symbols map
481+
// will be used instead (i.e. 'en')
482+
$slugger = new AsciiSlugger('en_GB', ['en' => ['%' => 'percent', '€' => 'euro']]);
483+
$slug = $slugger->slug('10% or 5€');
484+
// $slug = '10-percent-or-5-euro'
485+
480486
// for more dynamic substitutions, pass a PHP closure instead of an array
481487
$slugger = new AsciiSlugger('en', function ($string, $locale) {
482488
return str_replace('❤️', 'love', $string);
@@ -490,6 +496,10 @@ that only includes safe ASCII characters::
490496

491497
The feature to use a PHP closure to define substitutions was introduced in Symfony 5.2.
492498

499+
.. versionadded:: 5.3
500+
501+
The feature to fallback to the parent locale's symbols map was introduced in Symfony 5.3.
502+
493503
The separator between words is a dash (``-``) by default, but you can define
494504
another separator as the second argument::
495505

0 commit comments

Comments
 (0)