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

Scope config option to isolate translations #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vipera
Copy link
Contributor

@vipera vipera commented Dec 1, 2022

In my usage of this gem, I ran into a situation where I'd like two very related applications that are organizationally distinct but part of the same domain (e.g. public web application and its admin/management application) to connect to the same database.

However, I'd like them not to share translation data, and found that difficult to do without overriding methods in I18n::Backend::ActiveRecord. So instead, I added this feature to my fork, and wanted to see what you think about it and whether you'd be interested in having it in the main codebase.

Essentially I added a scope field to the migration and if the configuration option is set, then all reads/writes will be limited to only those records with that particular scope identifier. I wanted to maintain compatibility with existing tables that don't have a scope, or even newly created tables where someone wants to remove the scope field from the migration if they won't be using it.

I've added two tests showing how I think the behaviour should work and a readme paragraph. Thanks taking the time to look this over ☺️

Allow the entire backend to use translations only from a subset of
the translation records.
@vipera vipera changed the title Scope config option to isolate` translations Scope config option to isolate translations Dec 2, 2022
@timfjord
Copy link
Collaborator

timfjord commented Dec 5, 2022

It is looking good 👍🏻, there are some failed tests though

@vipera
Copy link
Contributor Author

vipera commented Dec 5, 2022

Thanks for your input, Tim!

I glanced over the pipeline logs and it looks like tests are failing on the master branch too for the same reasons. As usual, test pipelines stop being reliable after a while...

I can look into the details to try and fix it, but I don't think it's related to the change I made.

@timfjord
Copy link
Collaborator

timfjord commented Dec 5, 2022

Hmm, indeed, master is broken.
It would be great to fix the tests(if you have bandwidth of course) otherwise, I will try to fix master so we can go ahead with this is PR

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.

2 participants