Closed aleho closed 5 days ago
You can use the data attribute as shown in the section of the documentation you link ?
Yes, there are other ways of configuring the locale. I'm just saying that Translator has a feature to read html lang=""
but that feature requires an invalid value for lang
to be fully compatible with Symfony i18n.
In my opinion either the feature should be removed or fixed. As the fix would be trivial (as far as I can see right now), I'd rather see a fix. As it stands now it doesn't break with en
but would break with en_US
, which was unexpected, at least for me.
If you want to use the lang attribute of the html tag, and if your locale region and langage code differ, you're right it would currently requires a value not following the w3 spec.
What i understand here is the feature is working for users:
So i doubt it will be "removed"
But it does not "convert" en-US to en_US indeed. So.. would you have some time to open a PR? 😃
(Only constraint: any change should keep previous behaviour working, to not break existing apps)
@smnandre Done!
Thank you very much @aleho :)
Symfony locales are specified with an underscore to split country code from language code, e.g.
de_AT
.When using UX Translator it correctly detects the current locale if set via the HTML attribute:
Unfortunately, according to W3, this format is invalid, as the "subcode" has to be separated by a hyphen.
Using
doesn't work, because this format is not detected by Translator, resulting in no translations at all (only the string constants are returned).