Conversation
7579f87 to
823ef89
Compare
cc46179 to
1c76451
Compare
Owner
Author
|
I don't understand why tests are failing. Everything runs smoothly on my end with paralellization. It seems like new code is not considered. Maybe caching? Merging as is, I'll investigate more if this continues on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3
In this PR we move away from using the
Rosetta.localeglobal to scope translations for a given key to a given locale.The design and its pros and cons were previously explained in #3.
While working on #10, it became clear that we needed dedicated getters and setters for scoped translations. Things like:
A new
Translatedmodule is introduced, heavily inspired by what's been implemented in ActiveStorage in Rails itself. The main advantage of this design is that we can defer the setup of thehas_oneassociation when the parent model is saved.Additionnal logic can be implemented in
Rosetta::Translated::CreateandRosetta::Translated::Deleteto account for future needs and design evolution.Finally, the main blocker for implementing this was that we know available locales only at runtime. This is fine for existing locales, but new locales would not be associated to the TranslationKey model.
This is fixed by adding a listener to the after a new locale is created. Translated model are notified of the newly created locale and appropriate associations are setup.
rosetta/app/models/rosetta/locale.rb
Lines 36 to 38 in dc0efb0
Note: the corollary is that locale codes can't be updated after the locale is created.