Skip to content

Commit 641a1a5

Browse files
committed
minor #14776 [String] Feature 39178 (jontjs)
This PR was submitted for the 5.2 branch but it was merged into the 5.3-dev branch instead. Discussion ---------- [String] Feature 39178 Docs for symfony/symfony#39178 Documentation update for [String] Feature 39178 "AsciiSlugger's symbolsMap should apply to all locales for a language". Commits ------- 36a5c1a [String] Feature 39178
2 parents 9d03c8f + 36a5c1a commit 641a1a5

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)