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 profile language picker when account has no saved locale

Damian Legawiec275318eb57b3
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/profile.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/profile.tsx
index 3d17b3e885..2e998ef4e5 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/profile.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/profile.tsx
@@ -47,11 +47,22 @@ export const Route = createFileRoute('/_authenticated/$storeId/settings/profile'
component: ProfilePage,
})
+// The language the dashboard is currently displaying — persisted in
+// localStorage and applied by i18next at boot. Used as the profile language
+// fallback when the account has no saved `selected_locale`, so the picker
+// reflects what the user actually sees (and a save persists it) instead of
+// initializing to an empty value that matches no option and renders blank.
+function currentUiLocale(): string {
+ const available = getAvailableUiLocales().map((l) => l.code)
+ const active = i18n.resolvedLanguage ?? i18n.language
+ return active && available.includes(active) ? active : 'en'
+}
+
function meToFormValues(me: MeResponse): MeFormValues {
return {
first_name: me.user.first_name ?? '',
last_name: me.user.last_name ?? '',
- selected_locale: me.user.selected_locale ?? '',
+ selected_locale: me.user.selected_locale || currentUiLocale(),
}
}