-
-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Translator] Handle W3C locale format on document element #2390
Conversation
📊 Packages dist files size differenceThanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @aleho, and thank you for taking the subject!
This is a direct BC break for people using <html lang="{{ app.request.locale }}">
with a _
inside the locale, but the component is still experimental, good news! It means that we can break things :)
However, it miss the CHANGELOG update, and we can improve the documentation a little bit.
Also, can you update the test getLocale / default locale
to ensure that expect(getLocale()).toEqual('fr_FR')
when document.documentElement.lang = 'fr-FR';
?
Thanks!
Is it? Did I miss something? In my tests it didn't matter whether I used What doesn't work is using
If this isn't a BC break, does it still need a changelog entry? Or can this be a bug fix? Now with tests. Sorry about that, completely forgot to commit them. |
src/Translator/doc/index.rst
Outdated
#. Or with ``<html data-symfony-ux-translator-locale="{{ app.request.locale }}">`` attribute (e.g., `de_AT` or `de` for Symfony locale format) | ||
#. Or with ``<html lang="{{ app.request.locale|replace({ '_': '-' }) }}">`` attribute (e.g., `de-AT` or `de` for W3C spec compliant format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#. Or with ``<html data-symfony-ux-translator-locale="{{ app.request.locale }}">`` attribute (e.g., `de_AT` or `de` for Symfony locale format) | |
#. Or with ``<html lang="{{ app.request.locale|replace({ '_': '-' }) }}">`` attribute (e.g., `de-AT` or `de` for W3C spec compliant format) | |
#. Or with ``<html data-symfony-ux-translator-locale="{{ app.request.locale }}">`` attribute (e.g., ``de_AT`` or ``de`` using Symfony locale format) | |
#. Or with ``<html lang="{{ app.request.locale|replace({'_': '-'}) }}">`` attribute (e.g., ``de`` or ``de-AT`` or following HTML specifications) |
wdyt ?
Almost a feature here :) # CHANGELOG
+ ## 2.22.0
+
+ - Support both "fr-FR" and "fr_FR" format in html lang attribute
## 2.20.0
Something like this maybe ? (wording to illustrate only 😅 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to me after applying @smnandre suggestion
According to W3C[1] (and RFC1766) 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. Fixes symfony#2378 [1] https://www.w3.org/TR/html401/struct/dirlang.html#h-8.1.1
Thank you @aleho. |
According to W3C (and RFC1766) 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.