Repository navigation
Translate admin page titles and order state badges - #6685
Conversation
9ddb612 to
d94b384
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6685 +/- ##
==========================================
+ Coverage 92.30% 92.47% +0.16%
==========================================
Files 969 1056 +87
Lines 19847 21490 +1643
==========================================
+ Hits 18319 19872 +1553
- Misses 1528 1618 +90 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| "cart" => :graphite_light | ||
| }[order.state] || :yellow | ||
| component("ui/badge").new(name: order.state.humanize, color:) | ||
| component("ui/badge").new(name: I18n.t("spree.order_state.#{order.state}"), color:) |
There was a problem hiding this comment.
We should be able to get the humanized string in different locales. It seems like we are just missing state machine translations. To test, I dropped in some additional translation strings and was able to see this work against an order record:
# en.yml
en:
activerecord:
state_machines:
spree/order:
states:
complete: "EN translation"# fr.yml
en:
activerecord:
state_machines:
spree/order:
states:
complete: "FR translation"I18n.with_locale(:en) do
Spree::Order.first.human_state_name
end
# => "EN translation"
I18n.with_locale(:fr) do
Spree::Order.first.human_state_name
end
# => "FR translation"There was a problem hiding this comment.
Right but then we would need to add all of those translations. I would rather use the existing translations because the alternatives are duplicating them or figuring out what uses the existing ones and moving it all over.
There was a problem hiding this comment.
We don't necessarily need to move them all over now.
I see an opportunity to centralize all of the state machine state translations in the YAML long term, while also reducing complexity of the new solidus_admin templates in the short term and promoting a nicer way to get translated states for application developers.
There was a problem hiding this comment.
If we don't move them over then everything will still show in English which is what this is trying to solve so I copied the existing translations. It duplicates them all but we do get the nicer helper which we can use going forward
There was a problem hiding this comment.
Ah, sorry. By moving it all over I thought that you meant existing translations that should probably be moved over to the activerecord.statemachines.* prefixed strings.
Despite the duplication, I think this is valuable. 👍
d94b384 to
82b9761
Compare
82b9761 to
a819354
Compare
a819354 to
651b41c
Compare
Index page titles and the order, payment and shipment state badges on the orders list were always shown in English. They now use the admin's locale. Co-authored-by: Alistair Norman <alistair@super.gd>
Without this stores in other languages see order states in English. The translations are copied from each language's existing order state strings. Latvian and Vietnamese have none to copy, and Bulgarian and Korean are missing some states.
651b41c to
4246c21
Compare
|
Thanks @AlistairNorman |
…g-locales Translate admin page titles and order state badges
Index page titles and the order, payment and shipment state badges on the orders list were always shown in English. They now use the admin's locale.
Based on work by @nerijunior in #6419
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: