Skip to content

Commit

Permalink
Merge branch '6.4' into 7.2
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed Feb 13, 2025
2 parents e2674a3 + 3b9bf9f commit 283856e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dumper/XliffFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private function dumpXliff2(string $defaultLocale, MessageCatalogue $messages, ?
$metadata = $messages->getMetadata($source, $domain);

// Add notes section
if ($this->hasMetadataArrayInfo('notes', $metadata)) {
if ($this->hasMetadataArrayInfo('notes', $metadata) && $metadata['notes']) {
$notesElement = $dom->createElement('notes');
foreach ($metadata['notes'] as $note) {
$n = $dom->createElement('note');
Expand Down
18 changes: 18 additions & 0 deletions Tests/Dumper/XliffFileDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,24 @@ public function testDumpCatalogueWithXliffExtension()
);
}

public function testEmptyMetadataNotes()
{
$catalogue = new MessageCatalogue('en_US');
$catalogue->add([
'empty' => 'notes',
'full' => 'notes',
]);
$catalogue->setMetadata('empty', ['notes' => []]);
$catalogue->setMetadata('full', ['notes' => [['category' => 'file-source', 'priority' => 1, 'content' => 'test/path/to/translation/Example.1.html.twig:27']]]);

$dumper = new XliffFileDumper();

$this->assertStringEqualsFile(
__DIR__.'/../Fixtures/resources-2.0-empty-notes.xlf',
$dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0'])
);
}

public function testFormatCatalogueXliff2WithSegmentAttributes()
{
$catalogue = new MessageCatalogue('en_US');
Expand Down
20 changes: 20 additions & 0 deletions Tests/Fixtures/resources-2.0-empty-notes.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="fr-FR" trgLang="en-US">
<file id="messages.en_US">
<unit id="Ll7LrI6" name="empty">
<segment>
<source>empty</source>
<target>notes</target>
</segment>
</unit>
<unit id="hU8PAYC" name="full">
<notes>
<note category="file-source" priority="1">test/path/to/translation/Example.1.html.twig:27</note>
</notes>
<segment>
<source>full</source>
<target>notes</target>
</segment>
</unit>
</file>
</xliff>

0 comments on commit 283856e

Please sign in to comment.