Skip to content

Commit

Permalink
laminas#7: Pass translated message through placeholder compile
Browse files Browse the repository at this point in the history
  • Loading branch information
TotalWipeOut committed May 16, 2024
1 parent f5413d6 commit 56f4038
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Translator/PlaceholderPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
*
* @template InstanceType of Placeholder\PlaceholderInterface
* @extends AbstractPluginManager<InstanceType>
* @method Placeholder\PlaceholderInterface get(string $name)
* @method Placeholder\PlaceholderInterface get(string $name, ?array $options = null)
*/
class PlaceholderPluginManager extends AbstractPluginManager
{
/** @inheritDoc */
protected $aliases = [
'segment' => Placeholder\SegmentPlaceholder::class,
'colon' => Placeholder\SegmentPlaceholder::class,
'laravel' => Placeholder\SegmentPlaceholder::class,
'handlebar' => Placeholder\HandlebarPlaceholder::class,
Expand Down
16 changes: 14 additions & 2 deletions src/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,13 @@ protected function getTranslatedMessage(
}

if (isset($this->messages[$textDomain][$locale][$message])) {
return $this->messages[$textDomain][$locale][$message];
return $this->placeholder ?
$this->placeholder->compile(
$locale,
$this->messages[$textDomain][$locale][$message],
$placeholders
) :
$this->messages[$textDomain][$locale][$message];
}

/**
Expand All @@ -463,7 +469,13 @@ protected function getTranslatedMessage(
* ]
*/
if (isset($this->messages[$textDomain][$locale][$textDomain . "\x04" . $message])) {
return $this->messages[$textDomain][$locale][$textDomain . "\x04" . $message];
return $this->placeholder ?
$this->placeholder->compile(
$locale,
$this->messages[$textDomain][$locale][$textDomain . "\x04" . $message],
$placeholders
) :
$this->messages[$textDomain][$locale][$textDomain . "\x04" . $message];
}

if ($this->isEventManagerEnabled()) {
Expand Down

0 comments on commit 56f4038

Please sign in to comment.