minor #11464 [Translator] Use quote to surround invalid locale (lyrixx)
This PR was submitted for the 2.5 branch but it was merged into the 2.3 branch instead (closes #11464).
Discussion
----------
[Translator] Use quote to surround invalid locale
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
I got this message in one application (CLI):
```
[InvalidArgumentException]
Invalid locale: en_US .
```
It's not so easy to spot the issue.
Commits
-------
c9742ef
[Translator] Use quote to surround invalid locale
This commit is contained in:
commit
3177be50f8
@ -309,7 +309,7 @@ class Translator implements TranslatorInterface
|
|||||||
private function assertValidLocale($locale)
|
private function assertValidLocale($locale)
|
||||||
{
|
{
|
||||||
if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
|
if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale));
|
throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user