1

I'm trying to get Symfony 5.3's Translation Providers working with Crowdin in my app. I'm using ICU format, trying to translate from pseudo-language to English (from "user.button.add" to "Add User").

The connection up works fine, I can run bin/console translation:push crowdin --force to get all my strings from the local file to appear in their user interface.

Then I go to Crowdin and translate a string, save the translation, approve the translation and quit the editor.

My problem starts when I try to update the local file via the Symfony CLI.

The command I'm using is bin/console translation:pull crowdin --intl-icu --domains=messages --locales=en and I have three observations:

  1. When I remove my local translation file and run the command, a new file appears, but with default Symfony's translation (__user.button.add)
  2. When I run the command with the local file in place, it does not get updated with the translations present in Crowdin
  3. When I go to Crowdin and try to export the XLF file manually, it contains the translations as expected.

I have used localise.biz with some success, but the same set of steps does not work with Crowdin, which makes me think I might be missing something on the Crowdin side of things?

Any kick in the right direction would be appreciated. Thanks for reading.

Jan Klan
  • 667
  • 6
  • 16

1 Answers1

1

I have the same problem right now. I have two files for my two locales:

header+intl-icu.en.xlf
header+intl-icu.uk.xlf

They were extracted by these commands:

php bin/console translation:extract --force en --clean
php bin/console translation:extract --force uk --clean

All content of these files translated at crowdin. When i pull translations from crowdin the header+intl-icu.uk.xlf with UK locale updated and all OK:

<source>label.login</source>
<target>Увійти</target>

But header+intl-icu.en.xlf file with EN locale just modified but source and target was the same like before:

<source>label.login</source>
<target>__label.login</target>

And I start to dig in...

Crowdin translations managed by

crowdin-translation-provider/CrowdinProvider.php 

When we try to pull translations by the command

php bin/console translation:pull crowdin --force --intl-icu

This flow managed by the function in CrowdinProvider.php:

public function read(array $domains, array $locales): TranslatorBag

There is a peace of code that executes changing for translation files for different locales:

foreach ($locales as $locale) {
      if ($locale !== $this->defaultLocale) {
         $response = $this->exportProjectTranslations($locale, $fileId);
      } else {
         $response = $this->downloadSourceFile($fileId);
      }

      $responses[] = [$response, $locale, $domain];
}

So in my case if locale === uk used function

$this->exportProjectTranslations($locale, $fileId)

And if locale === en function

$this->downloadSourceFile($fileId);

If I remove this check for the defaultLocale locale all my translations from the crowdin start to work fine. And I don't know what to do next. Looks like it is a native behavior of crowdin-translation-provider.

KrOvean
  • 41
  • 3