diff --git a/src/Symfony/Component/Translation/Formatter/IntlFormatter.php b/src/Symfony/Component/Translation/Formatter/IntlFormatter.php index 1d5f468d46..ad4a45b95b 100644 --- a/src/Symfony/Component/Translation/Formatter/IntlFormatter.php +++ b/src/Symfony/Component/Translation/Formatter/IntlFormatter.php @@ -28,6 +28,11 @@ class IntlFormatter implements IntlFormatterInterface */ public function formatIntl(string $message, string $locale, array $parameters = []): string { + // MessageFormatter constructor throws an exception if the message is empty + if ('' === $message) { + return ''; + } + if (!$formatter = $this->cache[$locale][$message] ?? null) { if (!($this->hasMessageFormatter ?? $this->hasMessageFormatter = class_exists(\MessageFormatter::class))) { throw new LogicException('Cannot parse message translation: please install the "intl" PHP extension or the "symfony/polyfill-intl-messageformatter" package.'); diff --git a/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php b/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php index 45ce6d4f6e..37d982cf29 100644 --- a/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php +++ b/src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php @@ -82,6 +82,11 @@ _MSG_; '{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree', [4560, 123, 4560 / 123], ], + [ + '', + '', + [], + ], ]; }