Skip to content

Commit f4c9fee

Browse files
committed
Merge branch '4.4' into 5.2
* 4.4: [TwigBridge] Install symfony/intl to run tests on Travis [Translation] Make `name` attribute optional in xliff2
2 parents b037319 + b955445 commit f4c9fee

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"symfony/form": "^5.1.9",
3131
"symfony/http-foundation": "^4.4|^5.0",
3232
"symfony/http-kernel": "^4.4|^5.0",
33+
"symfony/intl": "^4.4|^5.0",
3334
"symfony/mime": "^5.2",
3435
"symfony/polyfill-intl-icu": "~1.0",
3536
"symfony/property-info": "^4.4|^5.1",

src/Symfony/Component/Translation/Dumper/XliffFileDumper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ private function dumpXliff2(string $defaultLocale, MessageCatalogue $messages, ?
150150
foreach ($messages->all($domain) as $source => $target) {
151151
$translation = $dom->createElement('unit');
152152
$translation->setAttribute('id', strtr(substr(base64_encode(hash('sha256', $source, true)), 0, 7), '/+', '._'));
153-
$name = $source;
154-
if (\strlen($source) > 80) {
155-
$name = substr(md5($source), -7);
153+
154+
if (\strlen($source) <= 80) {
155+
$translation->setAttribute('name', $source);
156156
}
157-
$translation->setAttribute('name', $name);
157+
158158
$metadata = $messages->getMetadata($source, $domain);
159159

160160
// Add notes section

src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function testFormatCatalogueXliff2()
4343
'foo' => 'bar',
4444
'key' => '',
4545
'key.with.cdata' => '<source> & <target>',
46+
'translation.key.that.is.longer.than.eighty.characters.should.not.have.name.attribute' => 'value',
4647
]);
4748
$catalogue->setMetadata('key', ['target-attributes' => ['order' => 1]]);
4849

src/Symfony/Component/Translation/Tests/fixtures/resources-2.0-clean.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@
1919
<target><![CDATA[<source> & <target>]]></target>
2020
</segment>
2121
</unit>
22+
<unit id="aF1tx51">
23+
<segment>
24+
<source>translation.key.that.is.longer.than.eighty.characters.should.not.have.name.attribute</source>
25+
<target>value</target>
26+
</segment>
27+
</unit>
2228
</file>
2329
</xliff>

0 commit comments

Comments
 (0)