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 #44085 [Translation] Fix TranslationPullCommand with ICU translations (Kocal)
This PR was squashed before being merged into the 5.3 branch.
Discussion
----------
[Translation] Fix TranslationPullCommand with ICU translations
| Q | A
| ------------- | ---
| Branch? | 5.3
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
Today I've faced an issue when trying to pull (ICU and non-ICU) translations from Loco:
- I have a non-ICU translation `say_hello` tagged as `messages`
- and a ICU translation `say_hello_icu` tagged as `messages+intl-icu`
When running `bin/console translation:pull loco --domains messages --domains messages+intl-icu`, it **only** creates a single file `messages.fr.xlf` that contains the two translations, so `say_hello_icu` will never be interpreted as an ICU-translation:
```xml
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="fr" target-language="fr" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
<trans-unit id="xQEX2ok" resname="say_hello_icu">
<source>say_hello_icu</source>
<target>Bonjour {name} !</target>
</trans-unit>
<trans-unit id="1IHotcu" resname="say_hello">
<source>say_hello</source>
<target>Bonjour %name% !</target>
</trans-unit>
</body>
</file>
</xliff>
```
With this fix, it creates two files as expected:
- `messages.fr.xlf`:
```xml
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="fr" target-language="fr" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
<trans-unit id="1IHotcu" resname="say_hello">
<source>say_hello</source>
<target>Bonjour %name% !</target>
</trans-unit>
</body>
</file>
</xliff>
```
- `messages+intl-icu.fr.xlf`:
```xml
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="fr" target-language="fr" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
<trans-unit id="xQEX2ok" resname="say_hello_icu">
<source>say_hello_icu</source>
<target>Bonjour {name} !</target>
</trans-unit>
</body>
</file>
</xliff>
```
I've also added more tests to `LocoProvider` and `TranslationPullCommand`, ensuring it still handle ICU translations in the future.
Ping `@welcoMattic`
Commits
-------
1802488 [Translation] Fix TranslationPullCommand with ICU translations
$this->assertStringContainsString('[OK] New translations from "null" has been written locally (for "en, fr" locale(s), and "messages" domain(s)).', trim($tester->getDisplay()));
84
+
$this->assertStringContainsString('[OK] New translations from "null" has been written locally (for "en, fr" locale(s), and "messages, messages+intl-icu"', trim($tester->getDisplay()));
0 commit comments