Skip to content

Commit

Permalink
[Translator] mention that the message id may also be an object that c…
Browse files Browse the repository at this point in the history
…an be cast to string in TranslatorInterface and fix the IdentityTranslator that did not respect this
  • Loading branch information
Tobion committed Feb 14, 2013
1 parent 7fc2f59 commit 82d1c91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions IdentityTranslator.php
Expand Up @@ -59,7 +59,7 @@ public function getLocale()
*/
public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
{
return strtr($id, $parameters);
return strtr((string) $id, $parameters);
}

/**
Expand All @@ -69,6 +69,6 @@ public function trans($id, array $parameters = array(), $domain = 'messages', $l
*/
public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
{
return strtr($this->selector->choose($id, (int) $number, $locale), $parameters);
return strtr($this->selector->choose((string) $id, (int) $number, $locale), $parameters);
}
}
4 changes: 2 additions & 2 deletions TranslatorInterface.php
Expand Up @@ -23,7 +23,7 @@ interface TranslatorInterface
/**
* Translates the given message.
*
* @param string $id The message id
* @param string $id The message id (may also be an object that can be cast to string)
* @param array $parameters An array of parameters for the message
* @param string $domain The domain for the message
* @param string $locale The locale
Expand All @@ -37,7 +37,7 @@ public function trans($id, array $parameters = array(), $domain = null, $locale
/**
* Translates the given choice message by choosing a translation according to a number.
*
* @param string $id The message id
* @param string $id The message id (may also be an object that can be cast to string)
* @param integer $number The number to use to find the indice of the message
* @param array $parameters An array of parameters for the message
* @param string $domain The domain for the message
Expand Down

0 comments on commit 82d1c91

Please sign in to comment.