Skip to content

Commit

Permalink
Added new methods clearTranslated and clearUntranslated
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemistr committed Apr 18, 2015
1 parent b77f014 commit f64fe12
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/l10n/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions tests/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit f64fe12

Please sign in to comment.