-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix reimbursement_category_name ending up in a translation missing error #3507
Fix reimbursement_category_name ending up in a translation missing error #3507
Conversation
@spaghetticode not sure if you are saying that this not needed anymore and it's an issue of how you are decorating files in your application. If it's needed we can take a look at the |
@kennyadsl I think the fix is still needed, it happens to every store that uses a Elia's solution works great but is specific for this situation; I'd prefer a more generic solution that would work for all instances where this problem could happen, both present and future. One solution that comes to my mind would be to load decorators after loading I18n translations... but not sure if this is feasible, so what we have now may be a good compromise... @elia any thoughts on this? |
@kennyadsl @spaghetticode I would avoid setting a value (unless static) until after the initialization, can be this way or via an actual initializer. So the options I see are:
Since I also object to falling back to |
@elia maybe we can just redefine the getter? This way the preference would work with the default value no matter where you call it? |
dd359a0
to
fb587a6
Compare
fb587a6
to
d3068e0
Compare
@kennyadsl I changed route altogether and moved the responsibility of fetching the store credit category for a reimbursement to the reimbursement itself via Hope this makes more sense and looks cleaner (especially once we'll throw away the deprecated stuff). |
d3068e0
to
eeff1f0
Compare
@elia did you have some time to take a look at the comments @aldesantis left? 🙏 |
I've agreed with @elia to take on the PR, I'm pushing some changes to address @aldesantis' comments 👍 |
eeff1f0
to
2aa7b81
Compare
@elia @filippoliverani this looks good overall. Could you guys just squash the commits? 🙏 |
2aa7b81
to
a5db6ba
Compare
@aldesantis done ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally dislike silencing deprecations outside of the specs. What if the method we are silencing calls another deprecated method?
Since it turned out that silence
is not yet thread-safe, I like it even less.
I'd prefer to explore an alternative.
This is the changelog provided from @elia Fixed how the default reimbursement store-credit category is fetched
Spree.config do |config|
config.use_legacy_store_credit_reimbursement_category_name = false
end If you had modifications in your codebase consider disabling the legacy behavior and porting them to a simple overwrite of |
@aldesantis @spaghetticode can you please review again when you have time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me, I left a note for a possible improvement, but I'm blocking because the last commit needs to be squashed.
|
||
before do | ||
create(:store_credit_category, name: 'foo') | ||
create(:store_credit_category, name: Spree::StoreCreditCategory::REIMBURSEMENT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use the new reimbursement
trait here
Replace a non-breaking-space with a regular one.
Add Spree::Reimbursement.store_credit_category_proc as a simple way to redefine how the reimbursement category should be fetched. Add Spree::Reimbursement#store_credit_category as the most natural way to fetch a given category for a reimbursement. This fixes reimbursement_category_name ending up in a translation missing error. We need to lazily load the translation because, when the file is loaded, Rails will still have to load translations from the main application. Co-Authored-By: Filippo Liverani <[email protected]>
9814a75
to
7ade8ca
Compare
@elia no need to squash the second commit, looks legit 👍 |
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
It removes: - .reimbursement_category_name - .reimbursement_category_name= - .reimbursement_category - #reimbursement_category_name ref: solidusio#3507
Description
While debugging the reason for which after the upgrade to Solidus 2.9 an application was still marking store credit with the "Gift Card" store credit category, I found that
Spree::StoreCreditCategory.reimbursement_category_name
contained the string"translation missing: en.spree.store_credit_category.default"
, although the I18n key was already set to "Reimbursement".The problem is that the I18n lookup is done before the Rails app is able to load the application translations.
Checklist: