You are here

public static function PluralizationRules::set in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/translation/PluralizationRules.php \Symfony\Component\Translation\PluralizationRules::set()

Overrides the default plural rule for a given locale.

Parameters

callable $rule A PHP callable:

string $locale The locale:

Throws

\LogicException

File

vendor/symfony/translation/PluralizationRules.php, line 197

Class

PluralizationRules
Returns the plural rules for a given locale.

Namespace

Symfony\Component\Translation

Code

public static function set($rule, $locale) {
  if ('pt_BR' === $locale) {

    // temporary set a locale for brazilian
    $locale = 'xbr';
  }
  if (strlen($locale) > 3) {
    $locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
  }
  if (!is_callable($rule)) {
    throw new \LogicException('The given rule can not be called');
  }
  self::$rules[$locale] = $rule;
}