8000 [Translation] Add XLIFF 1 source to metadata to differentiate from attr · symfony/symfony@ab04f25 · GitHub
[go: up one dir, main page]

Skip to content

Commit ab04f25

Browse files
committed
[Translation] Add XLIFF 1 source to metadata to differentiate from attr
1 parent f8664e7 commit ab04f25

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, s
105105
$catalogue->set((string) $source, $target, $domain);
106106

107107
$metadata = [
108+
'source' => (string) $translation->source,
108109
'file' => [
109110
'original' => (string) $fileAttributes['original'],
110111
],

src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function testEncoding()
8686
$this->assertEquals(utf8_decode('bär'), $catalogue->get('foo', 'domain1'));
8787
$this->assertEquals(
8888
[
89+
'source' => 'foo',
8990
'notes' => [['content' => utf8_decode('bäz')]],
9091
'id' => '1',
9192
'file' => [
@@ -175,6 +176,7 @@ public function testLoadNotes()
175176

176177
$this->assertEquals(
177178
[
179+
'source' => 'foo',
178180
'notes' => [['priority' => 1, 'content' => 'foo']],
179181
'id' => '1',
180182
'file' => [
@@ -186,6 +188,7 @@ public function testLoadNotes()
186188
// message without target
187189
$this->assertEquals(
188190
[
191+
'source' => 'extrasource',
189192
'notes' => [['content' => 'bar', 'from' => 'foo']],
190193
'id' => '2',
191194
'file' => [
@@ -197,6 +200,7 @@ public function testLoadNotes()
197200
// message with empty target
198201
$this->assertEquals(
199202
[
203+
'source' => 'key',
200204
'notes' => [
201205
['content' => 'baz'],
202206
['priority' => 2, 'from' => 'bar', 'content' => 'qux'],
@@ -304,6 +308,7 @@ public function testLoadWithMultipleFileNodes()
304308

305309
$this->assertEquals(
306310
[
311+
'source' => 'foo',
307312
'id' => '1',
308313
'file' => [
309314
'original' => 'file.ext',
@@ -313,6 +318,7 @@ public function testLoadWithMultipleFileNodes()
313318
);
314319
$this->assertEquals(
315320
[
321+
'source' => 'test',
316322
'notes' => [['content' => 'note']],
317323
'id' => '4',
318324
'file' => [

src/Symfony/Component/Translation/Tests/fixtures/withnote.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<target>bar</target>
88
<note priority="1">foo</note>
99
</trans-unit>
10-
<trans-unit id="2">
11-
<source>extra</source>
10+
<trans-unit id="2" resname="extra">
11+
<source>extrasource</source>
1212
<note from="foo">bar</note>
1313
</trans-unit>
1414
<trans-unit id="123">

0 commit comments

Comments
 (0)
0