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

Writing locales to nested folders #486

Open
v1nayv opened this issue Jan 12, 2023 · 4 comments
Open

Writing locales to nested folders #486

v1nayv opened this issue Jan 12, 2023 · 4 comments
Labels

Comments

@v1nayv
Copy link

v1nayv commented Jan 12, 2023

Hello,

I have a project where the yaml files are nested in multiple folders, somethng like
.
└── all_translations/
├── tanslations_set1/
│ └── en.yml
└── translations_set2/
└── en.yml

I can read the the files by pattern */ yml to read all the en.yml files. But when i write it it seems like i am restricted to just one path and the translations are all combined to one file .

How do i write back the missing translations to their respective folders ?

Looking for the end result like so
.
└── all_translations/
├── tanslations_set1/
│ ├── en.yml
│ ├── es.yml (generated)
│ └── fr.yml (generated)
└── translations_set2/
├── en.yml
├── es.yml (generated)
└── fr.yml (generated)

@davidwessman
Copy link
Collaborator

davidwessman commented Jan 12, 2023

You can setup rules based on the keys in the files with "data.write" in the config:

@v1nayv
Copy link
Author

v1nayv commented Jan 12, 2023

@davidwessman i see that, but the folder names are not in the yml file. Do you know how can i get the folder name in the write section to write the files at ?

For example:

read:
    - events/account_change/%{locale}.yml
    - events/extension_change/%{locale}.yml

  write:
    - events/account_change/%{locale}.yml
    - events/extension_change/%{locale}.yml

With this configuration the extension_change locale is not written to events/extension_change/%{locale}.yml , i18n tasks writes everything to events/account_change/%{locale}.yml

I would like something to the effect of the following , so that folder_name being written to is dynamic based on where its being read

  write:
    - events/%{folder_name}/%{locale}.yml

@davidwessman
Copy link
Collaborator

As far as I understand,
the normalize-tasks know nothing about the folder names or file names, it only knows the keys.

In my projects we have lots of rules to map the translations into:

  • config/locales/models
  • config/locales/controllers
  • config/locales/views

for example, but it is all based on the keys in the files.

@glebm
Copy link
Owner

glebm commented Jan 13, 2023

The pattern_router is based on key names. So you map key patterns to files.
If you want to simply keep the keys where they are, use conservative_router.

See https://github.com/glebm/i18n-tasks#multiple-locale-files

@glebm glebm added the question label Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants