@spree/docs 0.1.296 → 0.1.297
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -116,21 +116,42 @@ Asking the API which resources are translatable means a translation tool doesn't
|
|
|
116
116
|
|
|
117
117
|
## Translating the interface
|
|
118
118
|
|
|
119
|
-
Spree's own
|
|
119
|
+
Spree's own text — transactional emails, API error messages and validation messages — ships translated into 43 languages besides English as part of Spree itself. There is nothing to install. A key that a language does not translate yet is shown in English.
|
|
120
120
|
|
|
121
|
+
The admin dashboard carries its own translations, separate from these. See [Dashboard translations](../dashboard/customization/translations.md).
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
Regional variants such as `de-CH` or `pt-BR` hold only what differs from their base language and fall back to it. Regional English (`en-GB` and the like) falls back to `en`.
|
|
124
|
+
|
|
125
|
+
### Using fewer languages
|
|
126
|
+
|
|
127
|
+
Loading every language costs startup time and memory. An app that serves only some languages can list them, and Spree then loads only those, plus English:
|
|
128
|
+
|
|
129
|
+
```ruby server/config/application.rb
|
|
130
|
+
config.i18n.available_locales = [:en, :de, :fr]
|
|
124
131
|
```
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
### Changing a translation
|
|
134
|
+
|
|
135
|
+
> **TIP:** To change what a customer email says, edit it in the dashboard under **Settings → Emails → Templates** instead. Edits apply per store and per language, and need no deploy. See [Templates merchants edit in the dashboard](../customization/emails.md#templates-merchants-edit-in-the-dashboard) and the [Emails user guide](/user/settings/emails).
|
|
136
|
+
|
|
137
|
+
Locale files are for the text the dashboard does not edit: API error messages, checkout requirements, validation messages and staff emails. To change a word or add a language, add the key to a locale file in your app. Your file wins over the one Spree ships.
|
|
138
|
+
|
|
139
|
+
```yaml server/config/locales/de.yml
|
|
140
|
+
de:
|
|
141
|
+
spree:
|
|
142
|
+
checkout_requirements:
|
|
143
|
+
email_required: Bitte geben Sie Ihre E-Mail-Adresse ein
|
|
128
144
|
```
|
|
129
145
|
|
|
146
|
+
Every key lives under `spree`. To read one from your own Ruby code, use its full key:
|
|
147
|
+
|
|
148
|
+
```ruby server/app/services/my_app/checkout_check.rb
|
|
149
|
+
I18n.t('spree.checkout_requirements.email_required')
|
|
150
|
+
```
|
|
130
151
|
|
|
131
|
-
|
|
152
|
+
> **INFO:** `Spree.t` still works in 6.0 but is deprecated and will be removed in 6.1. Use `I18n.t` with the full `spree.` key instead.
|
|
132
153
|
|
|
133
|
-
|
|
154
|
+
Corrections to the translations Spree ships are welcome as pull requests to the locale files in the [Spree repository](https://github.com/spree/spree/tree/main/spree/core/config/locales).
|
|
134
155
|
|
|
135
156
|
## Related
|
|
136
157
|
|
|
@@ -53,7 +53,7 @@ that doesn't apply never appears at all:
|
|
|
53
53
|
applicable: ->(cart) { cart.customer&.company.present? }
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
`message` is stored verbatim — wrap it in `
|
|
56
|
+
`message` is stored verbatim — wrap it in `I18n.t` yourself if it needs translating.
|
|
57
57
|
|
|
58
58
|
## Adding a step
|
|
59
59
|
|
|
@@ -76,7 +76,7 @@ module MyApp
|
|
|
76
76
|
|
|
77
77
|
def authenticate
|
|
78
78
|
token = params[:token] || extract_bearer
|
|
79
|
-
return failure(
|
|
79
|
+
return failure(I18n.t('spree.api.unauthorized')) if token.blank?
|
|
80
80
|
|
|
81
81
|
payload = verify_with_jwks(token)
|
|
82
82
|
|
|
@@ -92,7 +92,7 @@ module MyApp
|
|
|
92
92
|
|
|
93
93
|
success(user)
|
|
94
94
|
rescue JWT::DecodeError, JWT::ExpiredSignature, JWT::InvalidIssuerError, JWT::InvalidAudError, KeyError => e
|
|
95
|
-
failure(
|
|
95
|
+
failure(I18n.t('spree.api.unauthorized'))
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
private
|
|
@@ -296,7 +296,7 @@ Spree::Checkout::Registry.add_requirement(
|
|
|
296
296
|
|
|
297
297
|
The requirement appears in the Cart API's `requirements` array (so a storefront rendering the feed generically needs zero changes) *and* blocks completion. `register_step` adds whole steps (spliced into `checkout_steps` at `before:`/`after:` anchors); built-in steps are customized through `Registry.base_steps` — an ordered `{ name => applicability }` hash you can mutate directly (`base_steps.delete('confirm')`).
|
|
298
298
|
- **The API `requirements` array now carries a stable `code`** on every entry (`email_required`, `out_of_stock`, `guest_checkout_not_allowed`, ...). Additive change — existing consumers keep working.
|
|
299
|
-
- **The delivery requirement is keyed `delivery_method`, not `shipping_method`.** Its entry is now `{ step: 'delivery', field: 'delivery_method', code: 'delivery_method_required' }`. A storefront that renders the feed generically needs no change; one that keys off the field or code to highlight a specific input must switch both tokens. The `
|
|
299
|
+
- **The delivery requirement is keyed `delivery_method`, not `shipping_method`.** Its entry is now `{ step: 'delivery', field: 'delivery_method', code: 'delivery_method_required' }`. A storefront that renders the feed generically needs no change; one that keys off the field or code to highlight a specific input must switch both tokens. The `spree.checkout_requirements.shipping_method_required` translation key was renamed to `spree.checkout_requirements.delivery_method_required` — override it under the new key.
|
|
300
300
|
- **"Logic between steps" has no backend home by design.** Side effects hang off data writes (workflow hooks such as `Carts::Complete`'s `before_finalize` and `Carts::AddItem`'s `after_item_added`) and events (`cart.updated`, `order.placed`) — not step transitions.
|
|
301
301
|
|
|
302
302
|
## Statuses: derived, then persisted
|
|
@@ -779,6 +779,18 @@ Other changes that come with it:
|
|
|
779
779
|
- **Alba moved into `spree_core`**, with its configuration, so core's staff emails render in installations without `spree_api`.
|
|
780
780
|
- **Your own mailers keep working.** A mailer that inherits `Spree::BaseMailer` and calls `mail` with its own ERB views is wrapped in the new email layout, and the `spree/shared/mailer_hero` and `mailer_button` partials remain for its views. See [Your own mailers](../customization/emails.md#your-own-mailers).
|
|
781
781
|
|
|
782
|
+
## Translations ship with Spree
|
|
783
|
+
|
|
784
|
+
Spree's translations for emails, API messages and validation messages are now part of Spree itself, in 43 languages besides English. Regional English (`en-GB` and the like) now falls back to `en`. A key a language does not translate yet falls back to English, unless your app configured its own `config.i18n.fallbacks`. See [Translations](../core-concepts/translations.md#translating-the-interface).
|
|
785
|
+
|
|
786
|
+
- **Remove `spree_i18n` from your Gemfile.** Its last release is empty and only warns. Older releases load their own, larger files over Spree's.
|
|
787
|
+
- **Use `I18n.t` with the full key.** `Spree.t(:free)` becomes `I18n.t('spree.free')`, and `Spree.t(:x, scope: :api)` becomes `I18n.t('spree.api.x')`. `Spree.t` keeps working until 6.1 with a deprecation warning.
|
|
788
|
+
- **A missing key is plain text.** `Spree.t` used to return a `<span class="translation_missing">` HTML element for a key it could not find. It now returns what `I18n.t` returns.
|
|
789
|
+
- **Untranslated keys fall back to English.** Spree's translations are complete only in English. With `config.i18n.fallbacks = true`, as Rails generates for production, Spree adds English after your default locale. An app that sets its own fallback list or turns fallbacks off keeps its choice.
|
|
790
|
+
- **`spree/testing_support/i18n` does nothing.** Set `config.i18n.raise_on_missing_translations = true` in your test environment to catch missing keys.
|
|
791
|
+
- **Kaminari is no longer loaded.** It came in through `spree_i18n`. Spree paginates with Pagy, and the `Spree::Base.page` bridge for a custom Kaminari `page_method_name` is gone. Add `kaminari` to your Gemfile if your own code uses it.
|
|
792
|
+
- **Translations for removed screens are gone.** Keys used only by the old admin and storefront, and by the v2 API, were removed. If your code reads one, copy it into your app's locale files.
|
|
793
|
+
|
|
782
794
|
## Deprecated in 6.0, removed in 6.1
|
|
783
795
|
|
|
784
796
|
Every rename keeps the legacy name working for one release with a deprecation warning. The notable ones:
|
|
@@ -825,6 +837,7 @@ Before 6.0 a cart was an incomplete order, so extensions written for 5.x (paymen
|
|
|
825
837
|
| `metafields` / `public_metafields` associations | `custom_fields` / `storefront_custom_fields` |
|
|
826
838
|
| `.with_metafield_key`, `.with_metafield_key_value` | `.with_custom_field_key`, `.with_custom_field_key_value` |
|
|
827
839
|
| `Spree.metafields` | `Spree.custom_fields` |
|
|
840
|
+
| `Spree.t`, `Spree.translate` | `I18n.t` with the full key, e.g. `I18n.t('spree.free')` |
|
|
828
841
|
| `CustomFieldDefinition#name`, `#metafield_type`, `#display_on` | `#label`, `#field_type`, `#storefront_visible` (columns renamed) |
|
|
829
842
|
| `Spree::SearchProvider::Meilisearch` | `SpreeMeilisearch::SearchProvider` (moved to the `spree_meilisearch` gem) |
|
|
830
843
|
| `Spree::SearchProvider::ProductPresenter` | `SpreeMeilisearch::ProductPresenter` (moved to the `spree_meilisearch` gem) |
|