Skip to content

Commit

Permalink
Added method Translator::hasLanguageAndPluralByCode($code)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemistr committed Apr 20, 2015
1 parent ae88643 commit 63c24c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/l10nNetteTranslator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ public function getLanguageAndPluralByCode($code) {
return $this->languages_and_plurals[$code];
}

/**
* @param string $code
* @return bool
*/
public function hasLanguageAndPluralByCode($code) {
return isset($this->languages_and_plurals[$code]);
}

/**
* @return \l10nNetteTranslator\LanguageAndPlural
* @throws InvalidStateException
Expand Down
10 changes: 10 additions & 0 deletions tests/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,14 @@ public function testTranslate() {
$this->assertSame('foo', $translator->translate('foo', 0));
$this->assertSame('foo', $translator->translate('foo', 0, []));
}

public function testHasLanguageAndPluralByCode() {
$translator = new Translator();
$language_and_plural = new LanguageAndPlural();

$this->setProperty($translator, 'languages_and_plurals', ['cs' => $language_and_plural]);

$this->assertTrue($translator->hasLanguageAndPluralByCode('cs'));
$this->assertFalse($translator->hasLanguageAndPluralByCode('sk'));
}
}

0 comments on commit 63c24c1

Please sign in to comment.