crowdin / github-action

A GitHub action to manage and synchronize localization resources with your Crowdin project
https://crowdin.com
MIT License
164 stars 56 forks source link

skip_untranslated_strings from config is not respected #212

Closed brawaru closed 9 months ago

brawaru commented 9 months ago

Describe the bug Having skip_untranslated_strings set to true for some of the files in crowdin.yml is not respected by the action (CLI?) and results in translation files being downloaded pre-filled from source.

To Reproduce

  1. Have crowdin.yml list some of the files which options have skip_untranslated_strings set to true.
  2. Try downloading translating via the action.

Expected behavior Untranslated strings are skipped in the downloaded files that have this option.

Screenshots N/A

Additional context Example from the repo I'm working on:

andrii-bodnar commented 9 months ago

@brawaru I just tested the skip_untranslated_strings set to true and it works as expected for me.

The only thing that might be related to the JSON file format is the following - https://crowdin.github.io/crowdin-cli/faq#json-empty-string-keys (empty string keys on export)

brawaru commented 9 months ago

Odd. It kind of works by passing --skip-untranslated-strings to download_translations_args of the action, but this applies to all downloaded files, which is not future-proof (e.g., what if we'd need a file that should be always pre-filled with source? Or file that should not be downloaded if it's untranslated?):

So I thought I'd individually change skip_untranslated_strings or skip_untranslated_files per file, but this is not working for whatever reason (see lines in the issue).

Is there some kind of way that these settings do not apply retroactively? That is, if file already exists on Crowdin and was uploaded without skip_untranslated_strings, then changing it later won't do anything.

Update 1: Just tried uploading sources again (run, crowdin.yml) and then downloading translations (run), but no, the downloaded files are still pre-filled with source strings (commit).

Update 2: Deleted the files and re-uploaded them again (run), then downloading translations (run). The files still have the source strings in it (commit). So retroactive theory doesn't hold. I'm completely confused now, can you take a look and see if I'm doing anything wrong?

andrii-bodnar commented 9 months ago

@brawaru thanks for the details! Please try using the skip_untranslated_strings Action input. As I can see from your crowdin.yml configuration file, you set the same skip_untranslated_strings: true for each file group, so there is no reason to do it at the config level.

To make sure the correct export option is passed in the API call, check the API logs of your Crowdin project. For example:

Screenshot 2024-02-07 at 15 34 49

brawaru commented 9 months ago

I found the culprit! I believe it was because I had pre-processor enabled. Since I heard Crowdin will export empty strings, I decided to see how I can delete those empty strings, but then quickly gave up. I didn't know how to remove the processor (you have to go to apps, find it there and uninstall), so I left it there thinking it wouldn't affect anything if it has no code, but apparently it did affect how translations are exported and caused all this confusion.

Sadly, though, it seems that I can only apply this option to all files at once and not individual files in crowdin.yml (which is quite confusing, why would it be listed in documentation then). That is quite unfortunate in case we were to have files that cannot be partial (compared to all others that can skip untranslated strings)...

andrii-bodnar commented 9 months ago

@brawaru the mixed export options should work. I just remembered that some time ago I prepared a working example for this case. Please take a look - https://github.com/andrii-bodnar/crowdin-mixed-export-options-demo

brawaru commented 9 months ago

Oh, I think I see, it doesn't work if you specify download_translations_args, which I do to add --all argument (because we plan to have some source files automatically generated and it doesn't make sense to automatically generate them again just to download translations).

brawaru commented 9 months ago

Oh, it's a problem with CLI, it downloads two different builds, but writes all files from each of them, thus overriding all files configured differently. I should've looked at the log, it's pretty obvious. I will open an issue on CLI repository.

Update: issue filed at https://github.com/crowdin/crowdin-cli/issues/724