Permalink
Browse files

[Translator] mention that the message id may also be an object that c…

…an be cast to string in TranslatorInterface and fix the IdentityTranslator that did not respect this
  • Loading branch information...
1 parent 7fc2f59 commit 82d1c911d51325705d626d465fd957ceb32ba7ae @Tobion Tobion committed Feb 13, 2013
Showing with 4 additions and 4 deletions.
  1. +2 −2 IdentityTranslator.php
  2. +2 −2 TranslatorInterface.php
View
@@ -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);
}
/**
@@ -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);
}
}
View
@@ -23,7 +23,7 @@
/**
* 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 @@ 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

0 comments on commit 82d1c91

Please sign in to comment.