Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Fix i18n lookup for select options with namespace separators (#14259)

Damian Legawiec4a745b86ecef
diff --git a/packages/dashboard/e2e/channels-settings.spec.ts b/packages/dashboard/e2e/channels-settings.spec.ts
index 6735274054..6dd809b7e9 100644
--- a/packages/dashboard/e2e/channels-settings.spec.ts
+++ b/packages/dashboard/e2e/channels-settings.spec.ts
@@ -79,6 +79,12 @@ test.describe('settings / channels', () => {
await expect(page.getByRole('heading', { name: original })).toBeVisible({ timeout: 15_000 })
await page.getByLabel(/^name$/i).fill(updated)
+
+ // Pick the routing strategy by its human label — the dropdown must surface
+ // readable option labels, never the raw strategy class name.
+ await page.locator('#preferred_order_routing_strategy').click()
+ await page.getByRole('option', { name: /^rules \(ordered\)$/i }).click()
+
await page.getByRole('button', { name: /^save$/i }).click()
await expect(rowButton(page, updated)).toBeVisible({ timeout: 15_000 })
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/channels.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/channels.tsx
index ea08b21d7e..cd942f98e0 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/channels.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/channels.tsx
@@ -331,7 +331,16 @@ function InheritableSelectField({
const error = form.formState.errors[name]
const options = values.map((value) => ({
value,
- label: value === '' ? t(`${scope}.inherit`) : t(`${scope}.options.${value}`),
+ // `nsSeparator: false` because option values can contain `::` (e.g. strategy
+ // class names), which i18next would otherwise parse as a namespace separator
+ // and miss the lookup.
+ label:
+ value === ''
+ ? t(`${scope}.inherit`)
+ : t(`${scope}.options.${value}`, {
+ nsSeparator: false,
+ defaultValue: value.replace(/^Spree::/, ''),
+ }),
}))
return (
<Field>