Exemplo n.º 1
0
 /**
  * @param \l10n\Language\ILanguage $language
  * @param \l10n\Plural\IPlural     $plural
  * @param bool                     $default
  */
 public function addLanguageAndPlural(ILanguage $language, IPlural $plural, $default = false)
 {
     $language_and_plural = new LanguageAndPlural();
     $language_and_plural->setLanguage($language);
     $language_and_plural->setPlural($plural);
     $code = $language->getIso639_1();
     $this->languages_and_plurals[$code] = $language_and_plural;
     if ($default || !$this->active_language_code) {
         $this->setActiveLanguageCode($code);
     }
 }
 public function testSettersAndGetters()
 {
     $language_and_plural = new LanguageAndPlural();
     $language_mock = $this->createLanguageMock();
     $language_and_plural->setLanguage($language_mock);
     $language = $language_and_plural->getLanguage();
     $this->assertSame($language_mock, $language);
     $plural_mock = $this->createPluralMock();
     $language_and_plural->setPlural($plural_mock);
     $plural = $language_and_plural->getPlural();
     $this->assertSame($plural_mock, $plural);
 }
 public function testTranslate()
 {
     $translator = new Translator();
     $plural = $this->createPluralMock();
     $language_and_plural = new LanguageAndPlural();
     $language_and_plural->setPlural($plural);
     $this->setProperty($translator, 'languages_and_plurals', ['cs' => $language_and_plural]);
     $this->setProperty($translator, 'active_language_code', 'cs');
     $this->assertSame('foo', $translator->translate('foo'));
     $this->assertSame('foo', $translator->translate('foo', 0));
     $this->assertSame('foo', $translator->translate('foo', 0, []));
 }