You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #42361 [Translation] correctly handle intl domains with TargetOperation (acran)
This PR was merged into the 4.4 branch.
Discussion
----------
[Translation] correctly handle intl domains with TargetOperation
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Executing `translations:update` with `--clean` was producing erratic result: creating duplicate non-/intl files for domains, removing used translations...
**TL;DR:** judging from context this was most probably just a typo in 33e6af5
# How to reproduce
## Setup Test Project
A fresh minimal project to verify this can be setup with
~~~sh
composer create-project symfony/skeleton translations_test
cd translations_test/
composer require translation
~~~
and adding extractable translations into a file in `src/`, e.g.
~~~php
<?php
// in src/translations.php
use Symfony\Component\Translation\TranslatableMessage;
new TranslatableMessage('First Message');
new TranslatableMessage('Second Message');
~~~
Otherwise any existing project should work as well.
## Steps to reproduce
### Case 1: duplicate translation files
~~~sh
# remove all existing translations and extract them again
rm -rf translations/*
php bin/console translation:update --force --clean en
# verify translations/messages+intl-icu.en.xlf was created containing the messages
# extract messages again
php bin/console translation:update --force --clean en
# messages+intl-icu.en.xlf is unchanged but messages.en.xlf with all the same messages was added
~~~
### Case 2: lost translations
~~~sh
# remove all existing translations and extract them again
rm -rf translations/*
php bin/console translation:update --force --clean en
# verify translations/messages+intl-icu.en.xlf was created containing the messages
# remove one or more messages from messages+intl-icu.en.xlf, keeping at least one
# extract messages again
php bin/console translation:update --force --clean en
# messages+intl-icu.en.xlf will *only* contain the missing/"new" messages and all other messages got removed
~~~
# The Fix
The previous code was trying to merge with the `target` messages instead of the `source`. This was probably just a typo since `$keyMetadata` is take from `source` just below it and the `foreach` block below which is basically doing the same inverse just switches `target` and `source`.
Also the code is mostly identical to [`MergeOperation`](https://github.com/symfony/symfony/blob/2cee75bef9f6c1ca4e532986dc0dcae8461de4dd/src/Symfony/Component/Translation/Catalogue/MergeOperation.php#L39-L46) which also uses `source` at the respective line.
The code in both files was introduced in 33e6af5
Commits
-------
84b48fe [Translation] correctly handle intl domains with TargetOperation
0 commit comments