phrase / phrase-cli

CLI for the Phrase API
https://developers.phrase.com
MIT License
42 stars 6 forks source link

Bug - `locale_mapping` is a Required Parameter (Not Optional) #144

Closed ahandsel closed 1 month ago

ahandsel commented 2 months ago

Problem

Contrary to what the Phrase Strings Upload a new file API documentation suggests, the locale_mapping parameter is required when using the phrase push command with a CSV file.

API Documentation

locale_mapping object Optional, format specific mapping between locale names and the columns the translations to those locales are contained in.

phrase.yml Template

Below is a snippet from the .phrase.yml template file:

locale_mapping: {"LANGUAGE_CODE": "COLUMN"} (object) #Optional, format specific (Excel, CSV) mapping between locale names and the columns the translations to those locales are contained in.

Solution

Please either:

Context

I was trying to use the phrase push command to upload a CSV file to update a Phrase Strings project. However, I encountered the following error:

API response: {"message":"Validation failed","errors":[{"resource":"Upload","field":"locale_mapping","message":"You must provide a locale_mapping parameter."}]}
ERROR: 422 Unprocessable Entity

I resolved the issue by adding the locale_mapping parameter to the .phrase.yml file. However, the documentation does not mention that this parameter is required.

phrase:
  access_token: #access_token
  project_id: #project_id
  file_format: csv
  push:
    sources:
      - file: ./upload-translations.csv
        params:
          file_format: csv
          locale_mapping: {"en": "2"}
  pull:
    targets:
      - file: ./<locale_name>-translations.csv

Environment

theSoenke commented 2 months ago

Hi @ahandsel, coincidentally I'm just working on updating some required params that were missed in the docs. Still for this case it depends on the format and I wouldn't mark it mark it as required for all formats. I'll try to at least note this in the description that it's required for some formats

ahandsel commented 2 months ago

@theSoenke Thank you for your reply. It would be helpful if it is specified in the .CSV (Strings) – Phrase help page that the locale_mapping is required.

theSoenke commented 1 month ago

Thanks for the feedback! now it's marked as required for both CSV and XSLX