コード例 #1
0
 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;
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
 public function testAllPluralRulesHandled()
 {
     $pluralRules = TestTranslation::getPluralRules();
     foreach ($pluralRules as $rule) {
         PluralRule::check($rule, 1);
     }
 }