Skip to content

Commit

Permalink
Do not require translators to return a string (#2)
Browse files Browse the repository at this point in the history
* T8031

* tweak
  • Loading branch information
aktorou committed Mar 26, 2021
1 parent 739645b commit 7660a37
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/SimplifiedTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

interface SimplifiedTranslatable
{
public function _t($text, array $replacements = null, $choice = null): string;
public function _t($text, array $replacements = null, $choice = null);

public function _p($singular, $plural, int $n, array $replacements = null): string;
public function _p($singular, $plural, int $n, array $replacements = null);

public function _sp($simplePlural, int $n, array $replacements = null): string;
public function _sp($simplePlural, int $n, array $replacements = null);
}
2 changes: 1 addition & 1 deletion src/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ interface Translatable
*
* @return string
*/
public function _($msgId, $default, array $replacements = null, $choice = null): string;
public function _($msgId, $default, array $replacements = null, $choice = null);
}
8 changes: 4 additions & 4 deletions src/TranslatableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ abstract protected function _getTranslator(): Translator;
'(o)' => 'oes',
];

public function _($msgId, $default, array $replacements = null, $choice = null): string
public function _($msgId, $default, array $replacements = null, $choice = null)
{
return $this->_getTranslator()->_($msgId, $default, $replacements, $choice);
}

public function _t($text, array $replacements = null, $choice = null): string
public function _t($text, array $replacements = null, $choice = null)
{
return $this->_getTranslator()->_(md5($text), $text, $replacements, $choice);
}

public function _p($singular, $plural, int $n, array $replacements = null): string
public function _p($singular, $plural, int $n, array $replacements = null)
{
return $this->_getTranslator()->_(
md5($singular . $plural),
Expand All @@ -41,7 +41,7 @@ public function _p($singular, $plural, int $n, array $replacements = null): stri
*
* @return mixed
*/
public function _sp($simplePlural, int $n, array $replacements = null): string
public function _sp($simplePlural, int $n, array $replacements = null)
{
return $this->_p(
str_replace(array_keys(static::$replacements), '', $simplePlural),
Expand Down

0 comments on commit 7660a37

Please sign in to comment.