crowdin / crowdin-cli

A command-line client for the Crowdin API
https://crowdin.github.io/crowdin-cli
MIT License
243 stars 88 forks source link

crowdin pre-translate error: <key: languageIds, code: notInArray, message: The input was not found in the haystack> #831

Closed bakua closed 2 weeks ago

bakua commented 1 month ago

Describe the bug Hello, when I try to run crowdin pre-translate --file=lib/l10n/intl_en.arb --method=mt --engine-id=##### I get the following error:

✔️ Fetching project info
❌ Pre-translation is running...
❌ Failed to pre-translate the project. Please contact our support team for help ❌ Wrong parameters: <key: languageIds, code: notInArray, message: The input was not found in the haystack>

To Reproduce Steps to reproduce the behavior:

  1. Configuration file:
    
    "project_id" : "###"
    "api_token" : "###"
    "base_path" : "."
    "base_url" : "https://api.crowdin.com"

"preserve_hierarchy": true

files: [ { "source" : "/lib/l10n/intlen.arb", "translation" : "/lib/l10n/intl%locale_with_underscore%.arb", } ]


3. Execute CLI command: per above
4. See an error

**Environment:**
 - OS: macos 14.5
 - crowdin cli version: 4.1.1
andrii-bodnar commented 1 month ago

Hi @bakua!

It looks like some of your project's target languages are not supported by the specified MT engine. Please try to specify languages to pre-translate (-l parameter).

By default, the pre-translate command tries to pre-translate all target languages if not explicitly specified.

bakua commented 1 month ago

Thank you, but how do I know which languages are not supported please? When I run pretranslate via website then it translates all my languages via the same engine.

andrii-bodnar commented 1 month ago

Are all languages available during UI pretranslation with this engine?

bakua commented 1 month ago

Yes, I just checked manually and the list of my all languages matches the list of languages in the pre-translate dialog.

andrii-bodnar commented 1 month ago

@bakua thanks for the details! Could you please share your Crowdin Project ID for further investigation?

bakua commented 1 month ago

Sure, it is ID: 426420

andrii-bodnar commented 1 month ago

@bakua it seems like there is a problem with the "Apply Pre-Translation" API method. For some reason, it returns Bad Request error when used with your MT engine and specific set of target languages. Could you please Contact our Customer Success Team for further investigation?

Thanks and sorry for the inconvenience!

RodriSanchez1 commented 1 month ago

Hi! I'm facing the same issue. I'm running the pre-translation from a GitHub Action. My project ID is 702517.

      - name: Pre-translate
        uses: crowdin/github-action@v2
        with:
          command: 'pre-translate'
          command_args: `'--method mt --file cbuilder/src/intl/cbuilder.json --engine-id ### --verbose'`
        env:
          CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
          CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

I'm using the Crowdin translation machine. When I run '--method mt --file cbuilder/src/intl/cbuilder.json --engine-id ### --verbose' , I expect all my languages to be translated. Instead, I get the same error as @bakua.

If I pass the -l argument, it works well. However, I also have a problem with that because it expects the language ID, and I cannot use the pre-translation method with a different language code.

For example, I have added French to my project. I'm using the locale code to identify the languages. If I try to run: '--method mt -l fr-FR --file cbuilder/src/intl/cbuilder.json --engine-id ### --verbose' , I get ❌ Language(s) 'fr-FR' doesn't exist in the project. Try specifying another language code(s) but if I use the fr code, it works well.

When I use es-ES, it works like a charm because the Crowdin code for es-ES is the same.

So how can I deal with this? Do I need to map all my locales with the Crowdin codes to be able to use the pre-translation method?

#crowdin.yml
'project_id_env': 'CROWDIN_PROJECT_ID'
'api_token_env': 'CROWDIN_PERSONAL_TOKEN'
# "base_path_env": "CROWDIN_BASE_PATH"
'base_path': './src/intl'
'base_url': 'https://api.crowdin.com'

'preserve_hierarchy': true

files: [
      'source': '/cbuilder.json',
      'translation': '/dictionaries/%locale%.json',
      'dest': '/cbuilder/src/intl/cbuilder.json',
      'type': 'json',
]
andrii-bodnar commented 1 month ago

HI @RodriSanchez1,

The crowdin pre-translate command (as well as any other CLI command) accepts only Crowdin Language Codes as the --language/-l parameter value.