diff --git a/src/l10n/Translator/Translator.php b/src/l10n/Translator/Translator.php index 8898eda..57bd464 100644 --- a/src/l10n/Translator/Translator.php +++ b/src/l10n/Translator/Translator.php @@ -131,6 +131,14 @@ public function removeUntranslated($key, $plural = 0) { } } + public function clearTranslated() { + $this->translated = array(); + } + + public function clearUntranslated() { + $this->untranslated = array(); + } + /** * @param string $key * @param int|array|null $n When $n is null, than singular will be selected. When $n is an array, it's used as $parameters. diff --git a/tests/TranslatorTest.php b/tests/TranslatorTest.php index c8e7851..45d2cc9 100644 --- a/tests/TranslatorTest.php +++ b/tests/TranslatorTest.php @@ -233,4 +233,28 @@ public function testSetAndRemoveUntranslated() { $translator->removeUntranslated('key_2'); $this->assertSame(array(), $translator->getUntranslated()); } + + public function testClearTranslated() { + $plural = $this->createPluralMock(); + + $translator = new Translator($plural); + $translator->setText('foo', 'bar'); + + $this->assertSame(array('foo' => array('bar')), $translator->getTranslated()); + + $translator->clearTranslated(); + $this->assertSame(array(), $translator->getTranslated()); + } + + public function testClearUntranslated() { + $plural = $this->createPluralMock(); + + $translator = new Translator($plural); + $translator->setUntranslated('foo'); + + $this->assertSame(array('foo' => array(true)), $translator->getUntranslated()); + + $translator->clearUntranslated(); + $this->assertSame(array(), $translator->getUntranslated()); + } }