[Translator] mention that the message id may also be an object that can be cast to string in TranslatorInterface and fix the IdentityTranslator that did not respect this

This commit is contained in:
Tobias Schultze 2013-02-13 02:44:53 +01:00
parent 5a36b2d5da
commit c97ee8dd48
2 changed files with 4 additions and 4 deletions

View File

@ -59,7 +59,7 @@ class IdentityTranslator implements TranslatorInterface
*/
public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
{
return strtr($id, $parameters);
return strtr((string) $id, $parameters);
}
/**
@ -69,6 +69,6 @@ class IdentityTranslator implements TranslatorInterface
*/
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);
}
}

View File

@ -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
@ -37,7 +37,7 @@ interface TranslatorInterface
/**
* 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