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

isolating router: only match files with configured locales #605

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gr8bit
Copy link

@gr8bit gr8bit commented Nov 6, 2024

Fixes too broad locale regexp

Problem

Internally, (*) was used to replace %{locale}, which was then translated to re regex part (.*), matching any yml-filename when %{locale}.yml was being used in read-section. So when using multiple files in the read section, translations often became scattered across the configured files.

Solution

As the locales in a Rails app can be configured almost freely (as the programmer pleases), I did not want to make assumptions about the used characters to replace the .*-regex. Instead, I am now using locales or base_locale from the configuration to match the locales, like this regex: (en|fr|de). It requires the user to set the available locales in the i18n-tasks.yml configuration file, at least for the isolating router.

Fixes #607

@glebm glebm marked this pull request as draft November 6, 2024 21:12
@gr8bit gr8bit changed the title [WIP] only match files with configured locales isolating router: only match files with configured locales Nov 12, 2024
@gr8bit gr8bit marked this pull request as ready for review November 13, 2024 11:26
@glebm
Copy link
Owner

glebm commented Nov 13, 2024

It requires the user to set the available locales in the i18n-tasks.yml configuration file, at least for the isolating router.

That seems like a very significant requirement change. Can we avoid requiring that somehow?

@gr8bit
Copy link
Author

gr8bit commented Nov 13, 2024

It requires the user to set the available locales in the i18n-tasks.yml configuration file, at least for the isolating router.

That seems like a very significant requirement change. Can we avoid requiring that somehow?

In order to keep the locale regex as non-greedy as possible, we could either

  1. specify the actual locales to match or
  2. make assumptions about the characters used in the locales and compile those into a regex

Maybe for 1. we could take the locales from somewhere else automatically? I don't know the depths of i18n-tasks so any input/help/suggestion would be appreciated. :)

@glebm
Copy link
Owner

glebm commented Nov 14, 2024

How about we simply fall back to the old behaviour if the locales aren't specified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Isolating router scrambles multiple files
2 participants