Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Admin UI owns its copy
Status: Implemented — all four migration steps shipped for 6.0
Target: Spree 6.0
Depends on: 6.0-admin-spa.md (i18n conventions, mapSpreeErrorsToForm)
Author: Damian Legawiec
Last updated: 2026-09-05
Summary
The React dashboard renders two kinds of human text it did not write: the
names and descriptions of pluggable types (price rules, promotion rules and
actions, calculators, collection rules, routing rules, delivery method rules,
commission rules, seller requirement kinds, integrations, the permission
catalog) and the messages inside 422 responses. Both are produced in Ruby
through Spree.t, in whatever locale the request resolved to, which the
dashboard never sets. A merchant using the dashboard in Polish on a store
whose default locale is English sees Polish chrome around English rule
names, and the reverse on a Polish store. Fixing one type at a time (PR
#14575 added en.yml keys for VolumeRule) keeps the split alive. This plan
moves every user-visible string the dashboard shows into the dashboard's own
locale files, and turns the Admin API's contribution into stable machine
codes plus a plain fallback. The Store API is not touched.
Key Decisions (do not deviate without discussion)
- The Admin API sends codes, the dashboard renders words. Type catalogs
and record serializers keep a stable snake_case
type; validation responses carry an errorcodeper attribute with its interpolation parameters. Nothing inpackages/dashboard*prints a Ruby-generated string when it has a key for the code. - Ruby keeps a human fallback, never the source of truth.
label,descriptionandmessagestay on the wire for integrations,curl, and extension types that ship no dashboard translation. They are documented as fallback text in the request locale, not as UI copy, and the dashboard uses them only wheni18n.exists()is false for the code. - The Store API is out of scope. The error handler is shared by both
halves, so the richer validation shape is added in the Admin base
controller, not in
Spree::Api::V3::ErrorHandler. Store responses stay byte-identical. - One helper, one key scheme, shared by both panels.
typeLabelandtypeDescriptionmove frompackages/dashboard/src/lib/type-labels.tsinto@spree/dashboard-core, keyed asadmin.types.<family>.<code>.{name,description}. The Seller Panel imports the same helper (dashboard is the reference, per the general rules). - UI language and content locale are different things. The dashboard
keeps not sending
x-spree-localefor its UI language. That header selects which Mobility translation of a product name the merchant reads and edits; binding it to the interface language would change the data a Polish admin edits on an English store. Content locale stays an explicit picker. - Type catalogs keep
label/descriptionas a documented fallback (2026-09-05). Dropping them would force every extension gem that ships a Ruby type to also ship a dashboard plugin with locales, or merchants read a raw code. Keeping them costs a few bytes per catalog entry and gives the migration itself a safety net. Built-in types still lose their Ruby copy methods anden.ymlkeys where those exist only to feed the wire; the fallback then resolves throughhuman_name. reject!takes the code as its first argument (2026-09-05):reject!(:not_awaiting_review),reject!(:below_minimum, count: 5). This reuseserrors.add(:base, symbol, **params)unchanged, so Rails resolves the message fromen.ymland records the code inerrors.detailswith no second signature to keep in sync. Strings keep working, so conversion is incremental and no call site breaks.- Every core error call site converts in this run (2026-09-05). All
errors.addandreject!sites carrying a preformatted string or aSpree.t/I18n.tmessage gain a symbolic code, so nomessage-only fallback path remains in core. Specs assert onerrors.detailscodes rather than English sentences. - The code is added alongside the message, not instead of it
(2026-09-05, found while implementing). Spree's error copy lives under
en.spree.errors.messages, but a bareerrors.add(:base, :some_code)resolves against Rails' top-levelen.errors.messagesand itsactiverecord.errors.*fallbacks — none of which Spree populates. Dropping the message would therefore replace every sentence with "Translation missing". The conversion iserrors.add(:attribute, :code, message: Spree.t('errors.messages.code')):errors.detailsgains the code the dashboard translates,errors.messageskeeps the text integrations already read, and interpolated messages keep their values. Moving the copy into Rails' scope was rejected — it would relocate hundreds of keys out of thespree:namespace that every extension'sSpree.tcall depends on. - Shared type-label and validation keys live in
@spree/dashboard-core(2026-09-05), which already ships all six locale files. The Seller Panel imports the helper and inherits every language without duplicating locale files intopackages/seller-dashboard. - Validation codes come from Rails, not from a new vocabulary.
errors.add(:attribute, :symbol, **params)already yieldserrors.details; workflows already routereject!throughActiveModel::Errorsand definemodel_namefor exactly this. The work is converting string andSpree.tcall sites to symbols, not inventing a parallel error registry.
Design Details
Type catalogs
Spree::PreferenceSchema.subclasses_with_preference_schema and the per-family
discovery actions (price_rule_types, rule_types, calculator lists, seller
requirement kinds) keep returning { type, label, description, preference_schema }. label and description are renamed nowhere and
removed nowhere; their OpenAPI descriptions change to "English fallback for
clients without their own translation of type". The record serializers
(PriceRuleSerializer, PromotionRuleSerializer, PromotionActionSerializer
and its nested calculator, CommissionRuleSerializer,
DeliveryMethodRuleSerializer, OrderRoutingRuleSerializer,
SellerRequirementSerializer, PermissionSerializer) drop the per-row
label/description/name copies. A row is rendered from its type and
the catalog the page already fetched, which is what the promotion editor does
today. DeliveryMethodRuleSerializer#name goes as well: it currently reuses
the attribute name a merchant would expect to be their own text.
Ruby loses the class-level copy methods that exist only for the wire:
Spree::Calculator.description literals, the human_description /
description pairs on rule base classes, and the price_rules.*,
promotion_rule_types.*-style keys in spree/core/config/locales/en.yml.
human_name stays as the fallback source and for console and log use.
Payment method and integration display_name are brand names, not copy, and
stay where they are.
Dashboard type labels
@spree/dashboard-core exports typeLabel(family, code, fallback) and
typeDescription(family, code, fallback). Families:
| Family | Today | Keys to add |
|---|---|---|
promotion_rule |
11 keys under admin.promotions.rule_types |
move |
promotion_action |
4 keys under admin.promotions.action_types |
move |
calculator |
11 name-only keys under admin.calculators |
move, add descriptions |
order_routing_rule |
3 keys | move |
collection_rule |
3 keys | move |
price_rule |
none | 6 |
commission_rule |
none | 4 |
delivery_method_rule |
none | 4 |
seller_requirement |
names only under admin.seller_requirements.kinds |
move, add descriptions |
integration |
none | per installed provider gem |
permission |
none | resource labels, descriptions and group labels |
Every key lands in all six locale files of both packages. Consumers that
still print the API string, and switch to the helper: price-list-form.tsx,
settings/commission-rates.tsx, settings/seller-requirements.tsx,
delivery-method-form.tsx, the seller panel delivery-methods.tsx,
configure-integration-sheet.tsx, settings/integrations.tsx,
permission-picker.tsx, calculator-summary.tsx in dashboard-ui (which
takes the resolved label as a prop, since dashboard-ui is headless).
Extensions that add a Ruby type register their copy with the dashboard plugin
they already ship for the editor form. defineDashboardPlugin gains a
locales contribution merged into i18next at boot; a plugin without one
falls back to the API label, which is the same experience as today.
Validation responses
Spree::Api::V3::Admin base overrides format_validation_details so an
Admin 422 reads:
{
"error": {
"code": "validation_error",
"message": "Name can't be blank, Quantity must be greater than 0",
"details": {
"name": [{ "code": "blank", "message": "can't be blank" }],
"quantity": [{ "code": "greater_than", "message": "must be greater than 0", "count": 0 }]
}
}
}
code is the symbol from errors.details; extra keys are the
interpolation options Rails recorded (count, value). A string added with
errors.add(:base, "text") has no symbol and serializes with code: null,
so the dashboard falls back to message. message is still the request
locale's Rails translation, which keeps curl and integrations readable.
mapSpreeErrorsToForm in dashboard-core resolves each entry as
admin.validation.codes.<attribute>.<code> then admin.validation.codes.<code>, with
message as the last resort, and interpolates the extra keys. The root
summary is rebuilt from the translated field messages instead of the server
sentence when every entry translated; otherwise the server message stays.
Each entry also carries specific, which says whether the model gave that
code its own wording. A code like invalid is generic and the client should
prefer its own translation, but the webhook URL validation reports invalid
and answers "must be a valid http or https URL" — translating the code there
would throw away the only part that tells the merchant what to do. Only the
server can tell the two apart, because the comparison is against the code's
default in the locale the message was resolved in; a client would have to
recognise that default in every language a store might trade in.
The codes namespace is deliberate: admin.validation.* already holds the
client-side keys the forms' own Zod schemas read (required, min_length,
invalid_email, …), and Rails' required (a missing belongs_to) means
something different from the client's (an empty input). Sharing one namespace
put "must exist" under every required field in the dashboard.
Rails' built-in codes (blank, taken, invalid, too_long,
greater_than, inclusion, and the rest of ActiveModel::Errors) get one
key each in admin.validation.codes. Custom codes get keys as their call sites are
converted: about 84 errors.add sites with string or Spree.t messages, 45
workflow reject! calls that pass Spree.t or I18n.t text, and 6 literal
English rejections in core become symbols with parameters. The en.yml
entries they used to read stay, because the fallback message still resolves
through them; only the dashboard stops depending on them.
Not moving
Store API serializers, controllers and error bodies. Transactional email
copy. Anything the Store API exposes to shoppers. display_* money
formatting, which is number formatting rather than copy.
Migration Path
All four steps shipped together for 6.0.
- Dashboard type labels (done). The helper moved into
@spree/dashboard-coreunder one key scheme (admin.types.<family>.<code>.{name,description}), covering 60 type codes across nine families in all six locales. Every consumer that printed the API string now resolves the code. Two promotion rules (channel,market) and eight permission catalog resources that had silently fallen through to English were filled in at the same time. - Admin validation shape (done).
Spree::Api::V3::Admin::ValidationDetailsoverridesformat_validation_detailson both admin branches, so each entry reports{ code, message, …interpolation }.mapSpreeErrorsToFormtranslates the code and falls back to the message. Store responses are unchanged, which a spec asserts directly. - Core error codes (done). All 94 preformatted
errors.addandreject!sites across core and the Stripe provider gained a symbolic code, with seven newen.ymlkeys for the messages that had none. Wording is byte-identical to what shipped before. - Serializer shrink (done). The per-row
label/description/namecopies are gone from all seven rule and action serializers, along with the nested calculator's label. The type catalogs keep theirs as the documented fallback.defineDashboardPlugingained alocalescontribution so a gem registering a Ruby type has somewhere to put its copy.
Constraints on Current Work
- A new pluggable type (rule, action, calculator, requirement kind) lands
with its
admin.types.<family>.<code>.{name,description}keys in every dashboard locale file. Do not add aSpree.tlabel for it inen.yml; the APIlabelmay keep readinghuman_nameas the fallback. - A dashboard page that renders a type picker or a rule row calls
typeLabel/typeDescription; never printentry.label,type.nameorrule.descriptiondirectly. The one exception is an integration'sname, which is a brand (Stripe, EasyPost) and is not translated — itsdescriptionis prose and does go through the helper. - New validation errors in core use a symbol and parameters
(
errors.add(:quantity, :greater_than, count: 0),reject!(:not_awaiting_review)), never a preformatted string, and the dashboard key for that code is added in the same PR. - Do not send the dashboard's UI language as
x-spree-localeto the Admin API. That header means content locale. - Do not touch
Spree::Api::V3::ErrorHandleror any Store serializer for this work. - Shared admin copy (type families, validation codes) goes in
packages/dashboard-core/src/locales/*.jsonin all six languages, never inpackages/seller-dashboard/src/locales/. The seller panel imports the helper rather than keeping its own copy of the keys.
Open Questions
None. The two questions this plan opened with (whether to keep the catalog
label/description fallback, and what shape reject! should take) were
settled on 2026-09-05 and moved into Key Decisions above.
References
- PR #14575 — the per-type
en.ymlfix this plan replaces as an approach packages/dashboard/src/lib/type-labels.ts— the existing partial helperpackages/dashboard-core/src/lib/form-errors.ts—mapSpreeErrorsToFormspree/api/app/controllers/concerns/spree/api/v3/error_handler.rb— shared 422 renderingspree/core/app/models/concerns/spree/preference_schema.rb— type catalog discoverydocs/plans/6.0-admin-spa.md— "Forms & i18n"