public function testLoaderLoadsPluralRules() { $loader = new PhpMemoryArrayLoader(include $this->testFilesDir . '/translation_en.php'); $textDomain = $loader->load('en_US', 'default'); $this->assertEquals(2, $textDomain->getPluralRule()->evaluate(0)); $this->assertEquals(0, $textDomain->getPluralRule()->evaluate(1)); $this->assertEquals(1, $textDomain->getPluralRule()->evaluate(2)); $this->assertEquals(2, $textDomain->getPluralRule()->evaluate(10)); }
/** * Load translations from a remote source. * * @param string $locale * @param string $textDomain * @return \Zend\I18n\Translator\TextDomain|null */ public function load($locale, $textDomain) { $words = $this->wordsServiceFinder->findMany(['Translate' => ['Languages' => ['Locale' => $locale]]]); $messages[$textDomain][$locale] = []; if ($words->count()) { foreach ($words as $word) { $messages[$textDomain][$locale][$word->getKey()] = $word->getTranslate(); } } $array = new PhpMemoryArray($messages); $result = $array->load($locale, $textDomain); return $result; }