Skip to content

Commit

Permalink
Fixed mess in code and updated comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemistr committed Apr 18, 2015
1 parent f76e9e9 commit bc4e0c6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/l10n/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public function getPlural() {
* @param int $plural
*/
protected function checkPlural($plural) {
if ($plural > ($max = $this->plural->getPluralsCount() - 1)) {
$max = $this->plural->getPluralsCount() - 1;

if ($plural > $max) {
throw new \RangeException(sprintf('The plural (%d) is bigger than is allowed (%d)', $plural, $max));
}
}
Expand Down Expand Up @@ -130,9 +132,9 @@ public function removeUntranslated($key, $plural = 0) {
}

/**
* @param string $key
* @param int|array $n When $n is null, than singular will be selected. When $n is an array, it's used as $parameters.
* @param array $parameters
* @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.
* @param array $parameters
* @return string
*/
public function translate($key, $n = null, array $parameters = array()) {
Expand All @@ -141,7 +143,12 @@ public function translate($key, $n = null, array $parameters = array()) {
$n = null;
}

$plural = $n === null ? 0 : $this->plural->getPlural($n);
$plural = 0;

if ($n !== null) {
$plural = $this->plural->getPlural($n);
}

$translated = $this->getText($key, $plural);

if ($translated === null) {
Expand Down

0 comments on commit bc4e0c6

Please sign in to comment.