You are here

protected function Translator::assertValidLocale in Plug 7

Asserts that the locale is valid, throws an Exception if not.

Parameters

string $locale Locale to tests:

Throws

\InvalidArgumentException If the locale contains invalid characters

6 calls to Translator::assertValidLocale()
Translator::addResource in lib/Symfony/translation/Translator.php
Adds a Resource.
Translator::getCatalogue in lib/Symfony/translation/Translator.php
Gets the catalogue by locale.
Translator::initializeCacheCatalogue in lib/Symfony/translation/Translator.php
Translator::initializeCatalogue in lib/Symfony/translation/Translator.php
Translator::setFallbackLocales in lib/Symfony/translation/Translator.php
Sets the fallback locales.

... See full list

File

lib/Symfony/translation/Translator.php, line 482

Class

Translator
Translator.

Namespace

Symfony\Component\Translation

Code

protected function assertValidLocale($locale) {
  if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
    throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
  }
}