Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple files per locale in push and pull commands #1

Open
bavdh opened this issue Nov 18, 2022 · 3 comments
Open

Support multiple files per locale in push and pull commands #1

bavdh opened this issue Nov 18, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@bavdh
Copy link

bavdh commented Nov 18, 2022

Unable to push files to localizely.

Expected behaviour:

$ localize-cli push --api-token <token> --project-id <project-id>
Successfully pushed data to Localizely

Actual behaviour:

$ localize-cli push --api-token <token> --project-id <project-id>
Failed to push localization file 'i18n/templates/baz.po' to Localizely
Error: 400 Bad Request

Here is my configuration localizely.yml file

config_version: 1.0.2
file_type: po
upload:
  files:
  - file: i18n/templates/foo.po
    locale_code: en
  - file: i18n/templates/bar.po
    locale_code: en
  - file: i18n/templates/baz.po
    locale_code: en
download:
  files:
  - file: i18n/en/foo.po
    locale_code: en
  - file: i18n/ne/foo.po
    locale_code: ne
  - file: i18n/en/bar.po
    locale_code: en
  - file: i18n/ne/bar.po
    locale_code: ne
  - file: i18n/en/baz.po
    locale_code: en
  - file: i18n/ne/baz.po
    locale_code: ne
@lzoran
Copy link
Collaborator

lzoran commented Nov 18, 2022

Hi @bavdh

Thanks for reporting this!

The current version of the CLI assumes that the upload and download config will use one file per locale rule.

In the attached example, the push command will try to send 3 times the same file (the last specified) for en locale, which results in a bad request error (the API client closes pushed file after the request, so following requests won't send any file data to server).

I see that there is a space for improvement. Maybe better error handling that will guide users to use one file per locale in config or extending current CLI to support multiple files per locale.

Also, could you share your motives to split translations for one locale in multiple files, so we can better understand the needs.

@bavdh
Copy link
Author

bavdh commented Nov 19, 2022

Hi @lzoran

Thanks for the reply!

I am working with multiple devices, and each device comes with a file containing its own instructions and configuration. Using a script the instructions are separated in a different file (a separate file containing instruction for each device). Now I need to translate these files per locale, and also maintain the separations after the translations(after download).

To make the push work I made some changes in the CLI by using its index rather than locale and it seems to do the trick for multiple files upload. But after a pull, I am getting separate files(as required) but containing all the translations in every of them (this maybe because CLI assumes one file per locale in pull as well).

It would be great if the CLI supports multiple files per locale (for both push and pull).

@lzoran
Copy link
Collaborator

lzoran commented Nov 23, 2022

Thanks for the provided info!

I suggest we leave this issue open so we can better track demand (upvotes) for the proposed functionality.

Until then, is it convenient for you to use tags and independent calls via CLI for the each file you need to translate?

Push translations from foo.po file:

localizely-cli push \
  --api-token <API_TOKEN> \
  --project-id <PROJECT_ID> \
  --files "file[0]=i18n/templates/foo.po","locale_code[0]=en"
  --overwrite \
  --reviewed=false \
  --tag-added foo \

Pull translations for foo.po file:

localizely-cli pull \
  --api-token <API_TOKEN> \
  --project-id <PROJECT_ID> \
  --file-type po \
  --files "file[0]=i18n/en/foo.po","locale_code[0]=en" \
  --export-empty-as empty \
  --include-tags foo \

*Note: This requires you to have unique keys across all localization files in case you use single Localizely project

@lzoran lzoran changed the title Bad Request on localize-cli push Support multiple files per locale in push and pull commands Nov 23, 2022
@lzoran lzoran added the enhancement New feature or request label Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants