You are here

protected function Translator::assertValidLocale in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/translation/Translator.php \Symfony\Component\Translation\Translator::assertValidLocale()

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 vendor/symfony/translation/Translator.php
Adds a Resource.
Translator::getCatalogue in vendor/symfony/translation/Translator.php
Gets the catalogue by locale.
Translator::initializeCacheCatalogue in vendor/symfony/translation/Translator.php
Translator::initializeCatalogue in vendor/symfony/translation/Translator.php
Translator::setFallbackLocales in vendor/symfony/translation/Translator.php
Sets the fallback locales.

... See full list

File

vendor/symfony/translation/Translator.php, line 457

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));
  }
}