Skip to content

Commit

Permalink
bug #26661 [Translation] XLIFF2: Make sure to trim source if it is to…
Browse files Browse the repository at this point in the history
…o 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
  • Loading branch information
fabpot committed Mar 30, 2018
2 parents f568271 + ca41fec commit 9b25573
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Symfony/Component/Translation/Dumper/XliffFileDumper.php
Expand Up @@ -146,7 +146,11 @@ private function dumpXliff2($defaultLocale, MessageCatalogue $messages, $domain,
foreach ($messages->all($domain) as $source => $target) {
$translation = $dom->createElement('unit');
$translation->setAttribute('id', strtr(substr(base64_encode(hash('sha256', $source, true)), 0, 7), '/+', '._'));
$translation->setAttribute('name', $source);
$name = $source;
if (strlen($source) > 80) {
$name = substr(md5($source), -7);
}
$translation->setAttribute('name', $name);
$metadata = $messages->getMetadata($source, $domain);

// Add notes section
Expand Down

0 comments on commit 9b25573

Please sign in to comment.