Skip to content

Commit

Permalink
Added getActiveLanguageCode into Translator
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemistr committed Jun 28, 2015
1 parent 5d1a9dc commit 412b30d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/l10nNetteTranslator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public function setActiveLanguageCode($code) {
$this->translator = null;
}

/**
* @return string|null
*/
public function getActiveLanguageCode() {
return $this->active_language_code;
}

/**
* @param string $code
* @return \l10nNetteTranslator\LanguageAndPlural
Expand Down
11 changes: 11 additions & 0 deletions tests/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ public function testSetActiveLanguageCode() {
$this->assertSame('en', $this->getProperty($translator, 'active_language_code'));
}

public function testSetAndGetActiveLanguageCode() {
$translator = new Translator();
$this->setProperty($translator, 'languages_and_plurals', ['cs' => true, 'en' => true]);

$translator->setActiveLanguageCode('cs');
$this->assertSame('cs', $translator->getActiveLanguageCode());

$translator->setActiveLanguageCode('en');
$this->assertSame('en', $translator->getActiveLanguageCode());
}

public function testGetLanguageByCodeWithException() {
$translator = new Translator();

Expand Down

0 comments on commit 412b30d

Please sign in to comment.