phrase-cli icon indicating copy to clipboard operation
phrase-cli copied to clipboard

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

Open ahandsel opened this issue 1 year ago • 2 comments

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:

  • Update the documentation (API and .phrase.yml example) to reflect this requirement.
  • Update the phrase-cli to handle the locale_mapping parameter as optional.

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

  • Phrase CLI version: 2.23.2
  • Device:
    • ProductName: macOS
    • ProductVersion: 14.4.1
    • BuildVersion: 23E224

ahandsel avatar Apr 16 '24 04:04 ahandsel

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

theSoenke avatar Apr 16 '24 11:04 theSoenke

@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.

ahandsel avatar Apr 17 '24 01:04 ahandsel

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

theSoenke avatar May 17 '24 07:05 theSoenke