From ab04f25da435eb8f8b7fcc957641b0ee3a5e2fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Thu, 7 Mar 2019 09:54:57 +0100 Subject: [PATCH] [Translation] Add XLIFF 1 source to metadata to differentiate from attr --- .../Component/Translation/Loader/XliffFileLoader.php | 1 + .../Translation/Tests/Loader/XliffFileLoaderTest.php | 6 ++++++ .../Component/Translation/Tests/fixtures/withnote.xlf | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index 78c3fe9381..2c59aeca16 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -105,6 +105,7 @@ class XliffFileLoader implements LoaderInterface $catalogue->set((string) $source, $target, $domain); $metadata = [ + 'source' => (string) $translation->source, 'file' => [ 'original' => (string) $fileAttributes['original'], ], diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php index f475c065b2..1ca8336d52 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php @@ -86,6 +86,7 @@ class XliffFileLoaderTest extends TestCase $this->assertEquals(utf8_decode('bär'), $catalogue->get('foo', 'domain1')); $this->assertEquals( [ + 'source' => 'foo', 'notes' => [['content' => utf8_decode('bäz')]], 'id' => '1', 'file' => [ @@ -175,6 +176,7 @@ class XliffFileLoaderTest extends TestCase $this->assertEquals( [ + 'source' => 'foo', 'notes' => [['priority' => 1, 'content' => 'foo']], 'id' => '1', 'file' => [ @@ -186,6 +188,7 @@ class XliffFileLoaderTest extends TestCase // message without target $this->assertEquals( [ + 'source' => 'extrasource', 'notes' => [['content' => 'bar', 'from' => 'foo']], 'id' => '2', 'file' => [ @@ -197,6 +200,7 @@ class XliffFileLoaderTest extends TestCase // message with empty target $this->assertEquals( [ + 'source' => 'key', 'notes' => [ ['content' => 'baz'], ['priority' => 2, 'from' => 'bar', 'content' => 'qux'], @@ -304,6 +308,7 @@ class XliffFileLoaderTest extends TestCase $this->assertEquals( [ + 'source' => 'foo', 'id' => '1', 'file' => [ 'original' => 'file.ext', @@ -313,6 +318,7 @@ class XliffFileLoaderTest extends TestCase ); $this->assertEquals( [ + 'source' => 'test', 'notes' => [['content' => 'note']], 'id' => '4', 'file' => [ diff --git a/src/Symfony/Component/Translation/Tests/fixtures/withnote.xlf b/src/Symfony/Component/Translation/Tests/fixtures/withnote.xlf index c045e21e23..f98cf7f97b 100644 --- a/src/Symfony/Component/Translation/Tests/fixtures/withnote.xlf +++ b/src/Symfony/Component/Translation/Tests/fixtures/withnote.xlf @@ -7,8 +7,8 @@ bar foo - - extra + + extrasource bar