How to specify languages_mapping?

In my Android project I like to use the %android_code% placeholder.

files:
  - source: /app/src/main/res/values/strings.xml
    translation: /app/src/main/res/values-%android_code%/%original_file_name%

This leads to regional values- folder being created by the export of translation files as show in this screenshot:

image

So far, so correct.

I would like to use the languages_mapping configuration parameter to map the regional language codes back to their two letters codes. Here is what I tried:

files:
  - source: /app/src/main/res/values/strings.xml
    translation: /app/src/main/res/values-%android_code%/%original_file_name%
    languages_mapping:
      two_letters_code:
        af: af
        dk: dk
        es: es

It seems like I did not configure it correctly because the folder do not change after syncing the configuration file.


I prefer defining the languages_mapping in the configuration file instead of the UI. The UI did not synchronize/write the mapping to the file. I want to maintain the configuration in one place.

Hi, this is the correct config:

files:
  - source: /app/src/main/res/values/strings.xml
    translation: /app/src/main/res/values-%android_code%/%original_file_name%
    languages_mapping:
      android_code:
        af: af
        en-DK: dk
        es-ES: es

In the languages_mapping configuration you need to specify the language placeholder name that you’re going to map, and also use the Crowdin Language Codes as keys in the languages list.

1 Like

Thank you. That works.

It is a bit hard to figure out the correct language codes. I think it would be good if the languages_mapping section in the documentation mentions that the left side refers to Crowdin language codes. A few examples certainly help, too.

Interestingly, the merge/pull request does not get updated. I would have expected that the now unused app/src/main/res/values-es-rES/strings.xml is removed. app/src/main/res/values-es/strings.xml is already there from when I used a different configuration. It seems the merge/pull request is additive. Is this on purpose?


Mind the typo in your answer: language_mapping → languages_mapping

Old merge request always remains the same, the new one should be created with new files and changes. Haven’t you received the new one?

Added a new section to the documentation - Advanced Usage | Crowdin CLI

3 Likes

I appreciate. By this the feature is much more accessible for first time users.

Old merge request always remains the same, the new one should be created with new files and changes.

Interesting. I would have expected that outdated files and folders are removed in a follow up commit. This way the branch is still non-invasive (changes can be undone at any time). Is the cumulative behavior documented somewhere?

Haven’t you received the new one?

New ones are now needed. They are there already in an earlier commit on the same branch from the time were I tried a different configuration.

Don’t about about the documentation, but it was like for the all time that pull requests were added, like request 1 is waiting, then request 2 and so on an so on. In past I can have like 15 requests waiting for approval :slight_smile: