8000 bug #26661 [Translation] XLIFF2: Make sure to trim source if it is to… · symfony/symfony@9b25573 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b25573

Browse files
committed
bug #26661 [Translation] XLIFF2: Make sure to trim source if it is too long for "name" (Nyholm)
This PR was merged into the 4.1-dev branch. Discussion ---------- [Translation] XLIFF2: Make sure to trim source if it is too long for "name" | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This PR is a follow-up on @javiereguiluz's comment here: symfony/symfony-docs#9302 This feature was introduced in #26149 Commits ------- ca41fec Make sure to trim source if it is too long
2 parents f568271 + ca41fec commit 9b25573

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ private function dumpXliff2($defaultLocale, MessageCatalogue $messages, $domain,
146146
foreach ($messages->all($domain) as $source => $target) {
147147
$translation = $dom->createElement('unit');
148148
$translation->setAttribute('id', strtr(substr(base64_encode(hash('sha256', $source, true)), 0, 7), '/+', '._'));
149-
$translation->setAttribute('name', $source);
149+
$name = $source;
150+
if (strlen($source) > 80) {
151+
$name = substr(md5($source), -7);
152+
}
153+
$translation->setAttribute('name', $name);
150154
$metadata = $messages->getMetadata($source, $domain);
151155

152156
// Add notes section

0 commit comments

Comments
 (0)
0