Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Translator] Make sure a null locale is handled properly#38127
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
9563ed4 tobe749d6CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
33a861b tod14f539Comparefabpot commentedSep 10, 2020
Tests seems broken by this change. |
ro0NL commentedSep 10, 2020
@jschaedl we need to ensure a fixed default locale still, see e.g.7fce86f#diff-59203b25094d9f89c0a4abd9864d8a9c |
d14f539 toa934e56Comparejschaedl commentedSep 16, 2020
@ro0NL Thanks for the hint :-) |
53e2d66 to1fb1f46Compare| publicfunctiongetLocale() | ||
| { | ||
| return$this->locale; | ||
| return$this->locale ?: \Locale::getDefault(); |
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.
Borrowed fromhttps://github.com/symfony/contracts/blob/master/Translation/TranslatorTrait.php#L38 which implies that an empty locale is not a valid locale.
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.
if we want to take this route, i would preserve the empty string (as given by the user)
and validate as such in assertValidLocale, rather than silently ignoring it.
I think it's worth a discussion on master.
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.
I think we could do this:
For now we deprecate the possibility to set en empty locale in 4.4 and stick with$this->locale ?? \Locale::getDefault(); for now and afterwards we add a proper validation inassertValidLocale on master.
WDYT?
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.
we cannot add new deprecations in a patch release either :)
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.
ah true 🙈
| publicfunctiongetValidLocalesTests() | ||
| { | ||
| return [ | ||
| [''], |
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.
not sure we should change this behavior in a patch release :/
the previous?? \Locale::getDefault() approach was fine no?
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.
Actually I am not sure too, but good point.
I thought it would be good to have bothTranslator andTranslatorTrait work the same way.
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.
I thought it would be good have both Translator and TranslatorTrait work the same way.
i think that's worth pursuing yes ... on master, then we wait for@nicolas-grekas's review also :)
1fb1f46 toac9bd5eComparejschaedl commentedSep 18, 2020
@ro0NL I reverted things as discussed. |
ac9bd5e to080ea5aComparefabpot commentedSep 18, 2020
Thank you@jschaedl. |
Aliance commentedSep 23, 2020
@fabpot are you planning to release a new version with this fix? |
jschaedl commentedSep 23, 2020
@Aliance A new patch version comes out at the end of every month.
You can subscribe for release notifications on this site:https://symfony.com/account/notifications |
Uh oh!
There was an error while loading.Please reload this page.