How to specify output path for crowdin cli translations with additional folders at the beginning?

I am using Crowdin CLI to download translations. I want to download the files from one path (flat, to be exact, so “/file.ext”) and to a path structured in another way e.g. “/folder/folder2/file.ext”.

How do I do that?

My current crowdin.yml that works in downloading from a flat structure to a flat structure:

"preserve_hierarchy": true

files: [
 {
  "source" : "/**/*.*",
  "translation" : "/%locale%/%original_file_name%"
 },
 {
  "source" : "/**/*.*",
  "translation" : "/%two_letters_code%/%original_file_name%"
 }
]

Extending the “translation” path to the desired “/folder/folder2/%two_letters_code%/%original_file_name%” causes the following error:

Downloaded translations don't match the current project configuration. 
The translations for the following sources will be omitted (...)

Hello @Prusio this error means that there’s no such files locally. Try adding these folders in you PC and run command once again.

And translation file path in Crowdin should be the same, go to Sources- > Files → (3 bullets → file settings → translation path).

As a result you should have following folders structure in both PC + translated path of the file in Crowdin.

Also this one can be used for checking mistakes in file:
crowdin lint

1 Like

I added the files locally and added the path into file settings. The error is now:

Due to missing respective sources, 
the following translations will be omitted:

The actual path to the settings was Content → Files → (3 bullets → Settings → Resulting file after translations export:) if it is wrong setting I changed please tell me where to find Sources?

The structure in settings matches exactly the “translation” path in yml.

I did rebuild the project after changing the settings. When I downloaded the files manually the translations were still in flat structure.

crowdin lint

Says
Your configuration file looks good

Just as it did previously.

Hello @Prusio

That’s translation path → path where translations would be stored in your laptop.

Sources are stored locally, in you PC or laptop. Is there any chance you can specify the source path a little bit, removing some asterisks and adding the folders or so, so it looks like /source_folder1/**/source_folder2/.

For now system grabs just everything from the space you’re running the CLI.

Also please keep in mind that both translation and source parent folders should be in the same space (like desktop, disc c, disc d or so on)

Probably you can even refer to dest

Any chance you can share the screenshot of how your files look in project in Crowdin (you can blur file/folders names, I just want to see the exact tree structure) ?

That’s translation path → path where translations would be stored in your laptop.

I completely do not understand that sentence. Please explain what you mean.

Sources are stored locally, in you PC or laptop. Is there any chance you can specify the source path a little bit, removing some asterisks and adding the folders or so, so it looks like /source_folder1/**/source_folder2/.
For now system grabs just everything from the space you’re running the CLI.

I can specify the source path. I still do not understand what it should be. It clearly is not referring to content of my local files, as I can run the CLI command in an empty folder and the translations appear in the first configuration I meantioned.

Nothing much to see in the project as it is simply a flat structure with one file for now:
Screenshot from 2022-08-10 12-09-26

Translation paths - is where translations are stored, it represents folders in your PC, so if you add some folders you need to have both path in crowdin.yml and file settings / translation export pattern updated so they became the same

If you have only 1 file, that there’s no need to have 2 times source + translations being written in configuration file.

Should be enough to delete everything and save only

“preserve_hierarchy”: true

files: [
 {
  "source" : "/**/*.*",
  "translation" : "/folder1/folder2/%locale%/%original_file_name%"
 }
]

In case you have locale you’ll be saved from conflicts that may arise if your file name is something like en.json, because in case you have English as translation in project, with 2 letters it would be “en”.

1 Like

Hello @Prusio, decided to jump here as well, can you provide me with the project id (in direct messages or here) so I’ll be able to check the logs from my side and say what’s the exact reason for such behavior?

@Dima I cannot find the option to DM on the site. I would prefer not to send the ID publicly.

@YuryChugov I used two files in the config to have translations with locale and with two letter codes.

Messaged you directly here and via email.

Hello @Prusio

So I’ve checked all from my side, here are some tips on the matter.

If you edit the “translation” key, please run “crowdin push” command first to update the files export pattern in Crowdin.

You can also do that manually via the Files tab (3 dots near file → settings → resulting file after translations export).

Then, with this config, on your hands, you run “crowdin pull”. It’s a future-oriented one, the config you’ve shared on the begging may have some conflicts in case the project will grow up.

"preserve_hierarchy": true

files: [
 {
  "source" : "/**/*.*",
  "translation" : "/folder/folder2/%two_letters_code%/%original_file_name%"
 }
]

Then, you can download translations and everything should be fine.

Please note that the project build may be skipped if you didn’t make any new translations, so after changing the pattern it’s a good idea to build the project via UI (just once) to re-build the structure:

Project homepage → Build & Download button

1 Like

Io clarify what I (and for that matter, my colleagues) did not understand is that “source” represent the structure both locally and on the server. What is more it was not clear for us that the translation path needed to be specified on the server also.

It is all relatively clear now. Thanks all!

1 Like

Glad to hear that all doubts are unveiled :wink: