Description
Symfony version(s) affected: 5.3.9
Description
Using Crowin as a translation provider, I have issue with the xlf file generated while pulling translations.
From what I've seen, generated translations are downloaded from the provider and sent over the XliffFileDumper to be saved inside my project. During this process, the property source-language is changed and no longer follow the default locale that I've setup in my project or defined in the downloaded source.
While my configuration say that my default locale should be french, command translation:pull doesn't take it into consideration.
framework:
default_locale: fr
translator:
default_path: '%kernel.project_dir%/translations'
fallbacks:
- fr
providers:
crowdin:
dsn: '%env(CROWDIN_DSN)%'
domains: [ 'messages' ]
locales: [ 'en', 'fr' ]
Here what I've been generated from the dumper :
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en-US" target-language="en" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
<trans-unit id="J8pHMY4" resname="Traduction">
<source>Simple traduction</source>
<target state="final">Simple translate</target>
</trans-unit>
</body>
</file>
</xliff>
Since the default locale is not sent as an option, the source-language is deduced by the Xliff Dumper using \Locale::getDefault() while it should be using the defined one.
Possible Solution
One way to fix it would be to add it in $writerOptions defined in TranslationPullCommand and add the default locale.
$writeOptions = [
'path' => end($this->transPaths),
'xliff_version' => $xliffVersion,
'default_locale' => $this->defaultLocale
];
The property is already injected to the command but doesn't seems to be used.