Skip to content

Commit

Permalink
Cast integer message id to string (#154)
Browse files Browse the repository at this point in the history
* Allow integer message id

* cast integer to string
  • Loading branch information
lulco authored and enumag committed Aug 20, 2018
1 parent bfc666f commit b892e00
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public function translate($message, $count = NULL, $parameters = [], $domain = N
} elseif ($message instanceof NetteHtmlString || $message instanceof LatteHtmlString) {
$this->logMissingTranslation($message->__toString(), $domain, $locale);
return $message; // what now?
} elseif (is_int($message)) {
$message = (string) $message;
}

if (!is_string($message)) {
Expand Down Expand Up @@ -182,6 +184,10 @@ public function translate($message, $count = NULL, $parameters = [], $domain = N
*/
public function trans($message, array $parameters = [], $domain = NULL, $locale = NULL)
{
if (is_int($message)) {
$message = (string) $message;
}

if (!is_string($message)) {
throw new \Kdyby\Translation\InvalidArgumentException(sprintf('Message id must be a string, %s was given', gettype($message)));
}
Expand All @@ -207,6 +213,10 @@ public function trans($message, array $parameters = [], $domain = NULL, $locale
*/
public function transChoice($message, $number, array $parameters = [], $domain = NULL, $locale = NULL)
{
if (is_int($message)) {
$message = (string) $message;
}

if (!is_string($message)) {
throw new \Kdyby\Translation\InvalidArgumentException(sprintf('Message id must be a string, %s was given', gettype($message)));
}
Expand Down

0 comments on commit b892e00

Please sign in to comment.