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:
Fabien Potencier 2014-07-24 18:59:35 +02:00
commit 3177be50f8
1 changed files with 1 additions and 1 deletions

View File

@ -309,7 +309,7 @@ class Translator implements TranslatorInterface
private function assertValidLocale($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));
}
}
}