Description
Symfony version(s) affected
5.x - 7.1
Description
Description:
In Symfony versions 5 and above, running the translation:push
command for the default locale without the --force
option leads to unintended behavior. The Crowdin translation source file is replaced with only the diff between local and remote translations, causing loss of data for all locales.
The root cause of this behavior lies in the following code inside the CrowdinProvider
if ($catalogue->getLocale() === $this->defaultLocale) {
if (!$fileId) {
$file = $this->addFile($domain, $content);
} else {
$file = $this->updateFile($fileId, $domain, $content);
}
if (!$file) {
continue;
}
$fileList[$file['name']] = $file['id'];
}
Here, the method updateFile
calls the Crowdin API method PUT files/{fileId}
, which fully replaces the file on Crowdin rather than merging the changes. As a result, the translation file on Crowdin is overwritten with only the local diff, leading to the loss of all other translations. If the --force
option is used then the newly created translation file contains all keys, old and new, and no data is being lost.
I’m unsure whether this is documented behavior or if there’s something incorrect in how I’m using translations or the Crowdin integration. I wasn't able to find documentation for this specific case, but my use of translations doesn't appear to be out of the ordinary.
How to reproduce
- Set up translations and crowdin-translations-provider
- Run
translation:push
for all locales. All translations keys are pushed as intended. - Update the local translation file for the default locale by adding some additional translation keys
- Run
translation:push
for the default locale without the--force
option. - Now the translation source file in Crowdin only contains the keys added in step 3, leading to loss of translations for all existing locales
Possible Solution
No response
Additional Context
No response