diff --git a/src/l10nNetteTranslator/Translator.php b/src/l10nNetteTranslator/Translator.php index 96b26ca..6ad1bfd 100644 --- a/src/l10nNetteTranslator/Translator.php +++ b/src/l10nNetteTranslator/Translator.php @@ -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 diff --git a/tests/TranslatorTest.php b/tests/TranslatorTest.php index 95c4886..3b90090 100644 --- a/tests/TranslatorTest.php +++ b/tests/TranslatorTest.php @@ -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();