This commit is contained in:
Paolo A
2024-08-13 13:44:16 +00:00
parent 1bbb23088d
commit e796d76612
4001 changed files with 30101 additions and 40075 deletions

View File

@@ -23,7 +23,7 @@ class TranslatableMessage implements TranslatableInterface
private array $parameters;
private ?string $domain;
public function __construct(string $message, array $parameters = [], string $domain = null)
public function __construct(string $message, array $parameters = [], ?string $domain = null)
{
$this->message = $message;
$this->parameters = $parameters;
@@ -50,12 +50,10 @@ class TranslatableMessage implements TranslatableInterface
return $this->domain;
}
public function trans(TranslatorInterface $translator, string $locale = null): string
public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
return $translator->trans($this->getMessage(), array_map(
static function ($parameter) use ($translator, $locale) {
return $parameter instanceof TranslatableInterface ? $parameter->trans($translator, $locale) : $parameter;
},
static fn ($parameter) => $parameter instanceof TranslatableInterface ? $parameter->trans($translator, $locale) : $parameter,
$this->getParameters()
), $this->getDomain(), $locale);
}