Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2fea95

Browse filesBrowse files
committed
Fix #33427
1 parent d26a656 commit e2fea95
Copy full SHA for e2fea95

File tree

2 files changed

+11
-1
lines changed
Filter options

2 files changed

+11
-1
lines changed

‎src/Symfony/Component/Translation/Tests/TranslatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Tests/TranslatorTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ public function getTransFileTests()
449449
public function getTransTests()
450450
{
451451
return [
452+
['', 'Empty string', '', [], 'fr', ''],
452453
['Symfony est super !', 'Symfony is great!', 'Symfony est super !', [], 'fr', ''],
453454
['Symfony est awesome !', 'Symfony is %what%!', 'Symfony est %what% !', ['%what%' => 'awesome'], 'fr', ''],
454455
['Symfony est super !', new StringClass('Symfony is great!'), 'Symfony est super !', [], 'fr', ''],
@@ -551,6 +552,9 @@ public function testIntlFormattedDomain()
551552

552553
$translator->addResource('array', ['some_message' => 'Hi {name}'], 'en', 'messages+intl-icu');
553554
$this->assertSame('Hi Bob', $translator->trans('some_message', ['%name%' => 'Bob']));
555+
556+
$translator->addResource('array', ['some_message' => ''], 'en', 'messages+intl-icu');
557+
$this->assertSame('', $translator->trans('some_message', []));
554558
}
555559

556560
/**

‎src/Symfony/Component/Translation/Translator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Translator.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,13 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul
213213
}
214214

215215
if ($this->hasIntlFormatter && $catalogue->defines($id, $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX)) {
216-
return $this->formatter->formatIntl($catalogue->get($id, $domain), $locale, $parameters);
216+
$message = $catalogue->get($id, $domain);
217+
// formatIntl uses MessageFormatter which constructor throws an exception if the message is empty
218+
if ('' === $message) {
219+
return '';
220+
}
221+
222+
return $this->formatter->formatIntl($message, $locale, $parameters);
217223
}
218224

219225
return $this->formatter->format($catalogue->get($id, $domain), $locale, $parameters);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.