You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #2390 [Translator] Handle W3C locale format on document element (aleho)
This PR was merged into the 2.x branch.
Discussion
----------
[Translator] Handle W3C locale format on document element
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| Issues | Fix#2378
| License | MIT
According to [W3C](https://www.w3.org/TR/html401/struct/dirlang.html#h-8.1.1
) (and [RFC1766](https://www.ietf.org/rfc/rfc1766.txt)) the valid format for language codes is "primary-code"-"subcode", but Symfony expects underscores as separator, resulting in broken translations.
This changes language codes specified in the correct format for HTML to the Symfony format when reading the "lang" attribute.
Commits
-------
8eab198 [Translator] Handle W3C locale format on document element
Copy file name to clipboardExpand all lines: src/Translator/doc/index.rst
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -90,9 +90,9 @@ Configuring the default locale
90
90
91
91
By default, the default locale is ``en`` (English) that you can configure through many ways (in order of priority):
92
92
93
-
#. With ``setLocale('your-locale')`` from ``@symfony/ux-translator`` package
94
-
#. Or with ``<html data-symfony-ux-translator-locale="your-locale">`` attribute
95
-
#. Or with ``<html lang="your-locale">`` attribute
93
+
#. With ``setLocale('de')`` or ``setLocale('de_AT')`` from ``@symfony/ux-translator`` package
94
+
#. Or with ``<html data-symfony-ux-translator-locale="{{ app.request.locale }}">`` attribute (e.g., ``de_AT`` or ``de`` using Symfony locale format)
95
+
#. Or with ``<html lang="{{ app.request.locale|replace({ '_': '-' }) }}">`` attribute (e.g., ``de-AT`` or ``de`` following the `W3C specification on language codes`_)
0 commit comments