Github integration with nested files

I have a Rails project and my translations files follow a structure that’s similar to the project structure itself. Example:

config/
  locales/
    models/
      en.yml
    views/
      en.yml
    en.yml

I would like to understand how can I set my github integration config in order to submit my files to be added according to this structure.

In my attempts, I managed the transifex integration bot to open some PRs to my project like this one: https://github.com/lidimayra/url-shortener/pull/24

This is an example of an es version of my translations files.

I would like it to be created at config/locales/views/home.es.yml
However, it’s being created at config/locales/es.yml/views/home.en.yml

My github integrations configs in transifex look like this:

filters:
  - filter_type: dir
    # all supported i18n types: https://docs.transifex.com/formats
    file_format: YML
    source_file_extension: yml
    source_language: en
    source_file_dir: /config/locales/LC_MESSAGES
    # path expression to translation files, must contain <lang> placeholder
    translation_files_expression: '/config/locales/<lang>.yml'

Hello @lidimayra,

Thank you for sharing all this information.

I think that your config file should look like the following

filters:
  - filter_type: dir
    # all supported i18n types: https://docs.transifex.com/formats
    file_format: YML
    source_file_extension: yml
    source_language: en
    source_file_dir: /config/locales/LC_MESSAGES
    # path expression to translation files, must contain <lang> placeholder
    translation_files_expression: '/config/locales/views/home.<lang>.yml' 

Could you please try this and share your feedback with us?

Thank you in advance.

Kind regards,
Panagiotis

1 Like

Hey @Panagiotis_Kavrakis, thank you for replying!! :slight_smile:

I guess my problem would be that files are located in views directory in this specific scenario, but I would be aiming for a more generic solution.

My yml files follow my Rails project structure:

So I would like to work with files that could be locate in views/ or in models/ or in any other directory inside config/locales. Is this possible to be achieved via github integration?

Hi @lidimayra,

Sorry for the misunderstanding. In that case, unfortunately with DIR as filter_type what you want is not supported because you have the language code as part of the translation filename and this is not supported. However, if you had the language code as a folder of your path and not part of the filename it could be supported and the config file will have the following format

filters:

  • filter_type: dir
    file_format: YML
    source_file_extension: yml
    source_language: en
    source_file_dir: /config/locales
    translation_files_expression: ‘/config/locales//home.yml’

Otherwise, you need to use the file option as filter_type and for each file, you will have a different setting in your config file. An example of that would like the following

filters:

  • filter_type: file
    source_file:/config/locales/LC_MESSAGES/views/home.yml
    file_format: YML
    source_language: en
    translation_files_expression: ‘/config/locales/views/home..yml’

filters:

  • filter_type: file
    source_file:/config/locales/LC_MESSAGES/models/home.yml
    file_format: YML
    source_language: en
    translation_files_expression: ‘/config/locales/models/home..yml’

etc…

Please let me know if that is clear for you now.

Thank you in advance.

Got it, it was quite clear. Thank you so much for your time and for the detailed explanation. :slight_smile: