Upload_sources option appends a slash to the translation file export settings

Hi Team,

Thanks for having such a great community to reach out for help :smiley:

I’m facing an issue when running the crowdin github action. I’m trying to upload my source file to my crowdin using the “upload_sources” action.

This is my config.yml file

project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN
files:
  - source: /locales-json/en.json
    update_option: update_without_changes
    translation: '%locale%.json'

and this is my github action workflow

  upload-sources-workflow:
    runs-on: [self-hosted, Linux]
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: crowdin action
        uses: freshactions/crowdin-github-action@1.4.0
        with:
          upload_sources: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
          CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

it works very well but with one small issue. Whenever I run this, the translation export setting also gets updated in crowdin with an “prepended slash” like below:

But I haven’t given any “slash” character in my crowdin.yml file. I can only manually remove the slash everytime from the settings but it will not solve the issue.

Is there any config param that can avoid appending the slash? Any help would be greatly appreciated.

Thanks

Hi Team,
It’s been almost a week since I posted this. Can you help me ?

Thanks

Hi @dragonsubbu
Well, by default, slash if required

May I wonder about your expectation? Why do you need slash to be removed? Perhaps you want a folder, and inside the translated file? If so, you may refer to our config file recommendation in CLI config section :slightly_smiling_face:

Hi @Dima

Yes, I want the translated files to be inside separate folders.
I checked the config section but couldn’t find any config related to my case.
Whenever I run my github action, it automatically adds the “slash” to the crowdin export configuration. Is it possible to prevent that behaviour?

@dragonsubbu

Slash is required by default, it’s a basic logic of CLI tools. Plus, we create a separate folder for each language you have (unless you’re using a specific format like multilingual spreadsheets). You may specify some direct folder/subfolders within translation_path, but still, a slash is needed to have.

@Dima

I have been using without the slash for a long time and when I export, the folder structure that used to get created will be like:
ar/ar-SA.json (or) bg/bg-BG.json
But after adding the slash, the folders are getting created for each language, but the json files are generated outside the folders.

Only when I’m running this github action, the slash gets added to the configuration

      - name: crowdin action
        uses: freshactions/crowdin-github-action@1.4.0
        with:
          upload_sources: true

is there a way to avoid updating the configuration ?

@dragonsubbu
Have you tried this translation path?
/%two_letters_code%/%locale%.json

Should work

@Dima Sorry wasn’t available for few days.

I don’t think /%two_letters_code%/%locale%.json will work for me since I use multiple languages with conflicting names like es-ES and es-MX etc.

The json file also shows a similar error like:
Screenshot 2022-03-14 at 12.06.35 PM

@dragonsubbu

Well, I guess, in this case, you can combine Language Mapping with a two_letters pattern.

In the projects settings (language mapping) you can add a mapping, for example, Spanish, Mexico → two letters code → “es-MX”, so it would become “es-MX” for both 2 letters and locale patterns.

Alternatively, try path like /%locale%/%locale%.json → it should create folder es-MX folder.

@Dima
I thought I can do some config changes to solve this easier. But since slash is mandatory as u said, I guess I need to make some code changes. I’ll try your suggestions as well.

Thanks a lot for your help.
Cheers :smiley:

@dragonsubbu yeah, slash is required by logic of system :slight_smile:
Still, I guess language mapping or locale pattern should hep.
In case any further clarification will be needed - just drop a note :slight_smile:

1 Like