-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
8000
[Translation] Xliff name attribute as the key. #37055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Hey, thanks for your report! |
I think this should be fixed. |
I have the same problem. |
@derrabus Yes ! |
nicolas-grekas
added a commit
that referenced
this issue
Feb 24, 2021
…rieMinasyan) This PR was submitted for the 5.2 branch but it was merged into the 4.4 branch instead. Discussion ---------- [Translation] Make `name` attribute optional in xliff2 Do not set a fake `name` attribute on `unit` element from xliff2 to allow using `source` attribute and avoid missing translation error | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes/no | New feature? | no | Deprecations? | no | Tickets | Fix #37055 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> When `xlf` translations are loaded, if a name exists on `unit` element, the segment's source is ignored: ```foreach ($xml->xpath('//xliff:unit') as $unit) { foreach ($unit->segment as $segment) { $attributes = $unit->attributes(); $source = $attributes['name'] ?? $segment->source; ``` At the same time, when dumping translations, the segment's source is copied into the unit's name attribute, unless it's longer than 80 characters. In that case, `substr(md5($source), -7)` is set into the name attribute. This results in a missing translation error, because the source is ignored and the name is a random string. Suggested solution: only set the name attribute if the string is less than 80 characters. Commits ------- 9705855 [Translation] Make `name` attribute optional in xliff2
Thanks guys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected: 5.1.0
Description
In the translation xliff dumper (translation/Dumper/XliffFileDumper.php), When a string length is greater than 80, the dumper (translation/Dumper/XliffFileDumper.php) set the name attribute of the unit using md5.
But since the xliff loader is now using the name attribute as the key (#35373), the translation is missing when generating the template.
How to reproduce
In a Twig template or using the translator->trans(), add a string to be translated with a length greater than 80 characters.
Dump the translation (I'm using the php-translation/symfony-bundle)
See the result in a browser: the translated string is always displayed in the default locale, plus, in the profiler, it is displayed as "missing" translation.
Possible Solution
I know I can use translation keys, but prefer to stick with content strings.
The text was updated successfully, but these errors were encountered: