Skip to content

Commit 283856e

Browse files
Merge branch '6.4' into 7.2
* 6.4: Fixes XliffFileDumperTest for 6.4 [HttpClient] Don't send any default content-type when the body is empty [VarExporter] Fix lazy objects with hooked properties [Translation] check empty notes ntfy-notifier: tfix in description
2 parents e2674a3 + 3b9bf9f commit 283856e

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

Dumper/XliffFileDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private function dumpXliff2(string $defaultLocale, MessageCatalogue $messages, ?
176176
$metadata = $messages->getMetadata($source, $domain);
177177

178178
// Add notes section
179-
if ($this->hasMetadataArrayInfo('notes', $metadata)) {
179+
if ($this->hasMetadataArrayInfo('notes', $metadata) && $metadata['notes']) {
180180
$notesElement = $dom->createElement('notes');
181181
foreach ($metadata['notes'] as $note) {
182182
$n = $dom->createElement('note');

Tests/Dumper/XliffFileDumperTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,24 @@ public function testDumpCatalogueWithXliffExtension()
148148
);
149149
}
150150

151+
public function testEmptyMetadataNotes()
152+
{
153+
$catalogue = new MessageCatalogue('en_US');
154+
$catalogue->add([
155+
'empty' => 'notes',
156+
'full' => 'notes',
157+
]);
158+
$catalogue->setMetadata('empty', ['notes' => []]);
159+
$catalogue->setMetadata('full', ['notes' => [['category' => 'file-source', 'priority' => 1, 'content' => 'test/path/to/translation/Example.1.html.twig:27']]]);
160+
161+
$dumper = new XliffFileDumper();
162+
163+
$this->assertStringEqualsFile(
164+
__DIR__.'/../Fixtures/resources-2.0-empty-notes.xlf',
165+
$dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0'])
166+
);
167+
}
168+
151169
public function testFormatCatalogueXliff2WithSegmentAttributes()
152170
{
153171
$catalogue = new MessageCatalogue('en_US');
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="fr-FR" trgLang="en-US">
3+
<file id="messages.en_US">
4+
<unit id="Ll7LrI6" name="empty">
5+
<segment>
6+
<source>empty</source>
7+
<target>notes</target>
8+
</segment>
9+
</unit>
10+
<unit id="hU8PAYC" name="full">
11+
<notes>
12+
<note category="file-source" priority="1">test/path/to/translation/Example.1.html.twig:27</note>
13+
</notes>
14+
<segment>
15+
<source>full</source>
16+
<target>notes</target>
17+
</segment>
18+
</unit>
19+
</file>
20+
</xliff>

0 commit comments

Comments
 (0)