Xcstrings sync w/ crowdin cli removes source text

Since https://github.com/crowdin/crowdin-cli/issues/486 has been fixed, crowdin download successfully fetches translations to our InfoPlist.xcstrings file. However, it also removes the English source text from that file.

crowdin.yml (roughly):

project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN
preserve_hierarchy: true

files:
  - source: /ios/InfoPlist.xcstrings
    dest: /ReactNative/InfoPlist.xcstrings
    translation: /ios/InfoPlist.xcstrings
    multilingual: true

crowdin CLI command:

crowdin download

When I run that, InfoPlist.xcstrings no longer contains any English text, just the translations into other languages. The file in question is https://crowdin.com/editor/inaturalistios/728

Is this a bug or do I need to change my config somehow?

Hi @kueda , let us check this with the team and get back to you

Hi @kueda ! can you please disable the export option (in the project settings) Export only approved translations and try downloading again?

Yes, when I uncheck “Export only approved translations” and run crowdin download, the en strings are omitted from InfoPlist.xcstrings.

Please make sure that you don’t use additional export parameters such as "skipUntranslatedStrings": true during the translation download

I didn’t use skipUntranslatedStrings: true, I just ran crowdin download with the config specified in the OP.

As I can see the export option “Export only approved translations” is still enabled in the project, please uncheck it here:
https://crowdin.com/project/inaturalistios/settings#export

Yes, we have multiple code repos pulling from that Crowdin project so I don’t want to leave that setting unchecked and destabilize them, so I unchecked it temporarily, then ran crowdin download as I said and got the result I described.

What are you expecting to happen when I run crowdin download after unchecking “Export only approved translations”? We don’t actually want to incorporate unapproved translations into any of our code so if this is your solution to this problem, it won’t work for us in the long term.

Hi @kueda , the cause is that you have an English target language, and since the file is multilingual, when exporting we pull strings from the target language first, not from the source.

To avoid this behavior, you can go in two ways:

  1. Remove the English target language
  2. Do not use the Skip untranslated strings option, use only Export only approved translations (but in this case, all existing locales will be filled with the source string)

Thank you, that seems to have worked! For the record and for anyone else experiencing similar problems, I disabled English (en) as a translation language only for this file, ran crowdin download again, and it worked with no other changes. However, changing the target language seemed to remove all existing translations for that file and I had to repopulate them with pre-translation and Translation Memory, which was fine but not ideal.

However, I think these are problems you at Crowdin should be handling on your end. An .xcstrings file specifies which locale is the source locale in the sourceLanguage attribute, so a Crowdin manager like me should not need to tell Crowdin that it should not be writing translations to that file for that locale.

FWIW, after trying to get this xcstrings integration to work correctly, I have three changes in functionality I’d like to request:

  1. Crowdin should never write translations to an xcstrings file for the locale specified in the sourceLanguage attribute of that file.
  2. multilingual: true should be the default configuration for xcstrings files, i.e. authors of crowdin.yml config files should not have to specify that because xcstrings files are always multilingual.
  3. Crowdin should automatically hide from translators any strings in an xcstrings file that specify "shouldTranslate": false
  4. If the above cannot be changed, these requirements should all be documented (maybe at https://store.crowdin.com/xcstrings)

Hi @kueda passed your request to the development team to consider

Hi @kueda

Have an update from our development team, please see below:

  1. So, why do you translate this file into English, if you don’t want the strings to be rewritten? The only improvement that can be made here is to take into account the excluded language for cases like yours, but since it’s the only request we’ve received so far, this change will not be released anytime soon.

  2. At the CLI level there is no way to make it automatic due to the specifics of the approach in validating the config file.

  3. This task (Support for shouldTranslate in xcstrings format - #4 by Dima) was released and it should be supported already.

  4. In the CLI documentation, all the necessary information about it already exists.