public function load($locale, $filename) { $resolvedIncludePath = $this->resolveViaIncludePath($filename); $messages = Yaml::parse($resolvedIncludePath); $textDomain = new TextDomain($messages); if (array_key_exists('', $textDomain)) { if (isset($textDomain['']['plural_forms'])) { $textDomain->setPluralRule(PluralRule::fromString($textDomain['']['plural_forms'])); } unset($textDomain['']); } return $textDomain; }
/** * Plural case * * Which plural form should be used * * Gettext formulas are eval-able, substitute n in the formula, and treat as a php expression * * @param string locale * @return int */ protected static function _pluralCase($n, $locale = null) { $rule = static::_pluralRule($locale); return PluralRule::check($rule, $n); }
public function testAllPluralRulesHandled() { $pluralRules = TestTranslation::getPluralRules(); foreach ($pluralRules as $rule) { PluralRule::check($rule, 1); } }