fix(i18n): sweep hardcoded 'en-US' from non-loyalty JS to I18n.locale
Some checks failed
CI / ruff (push) Successful in 16s
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / pytest (push) Has been cancelled

Follow-up to dd1f9af8 which fixed loyalty. The same hardcoded 'en-US'
in toLocaleDateString / toLocaleString / Intl.NumberFormat appeared in
13 files across catalog, marketplace, orders, tenancy, inventory,
monitoring, cms, the storefront layout, and the shared Utils helper
itself. After this sweep, no non-loyalty JS hardcodes 'en-US' anymore;
all use I18n.locale and respect the user's dashboard language.

The highest-leverage one is static/shared/js/utils.js (Utils.formatDate
/ Utils.formatDateTime / Utils.formatCurrency / Utils.formatNumber) —
those four helpers are called from across the frontends so this one
edit fixes most secondary callsites for free.

Codemod scope was conservative: only replaced 'en-US' when it
appeared as the first argument to toLocale* or new Intl.* calls, to
avoid touching unrelated occurrences (none found, but the guard
matters if more get added).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-24 23:38:35 +02:00
parent a21dbbcddf
commit 06e59f73b3
13 changed files with 17 additions and 17 deletions

View File

@@ -15,7 +15,7 @@ const Utils = {
try {
const date = new Date(dateString);
return date.toLocaleDateString('en-US', {
return date.toLocaleDateString(I18n.locale, {
year: 'numeric',
month: 'short',
day: 'numeric'
@@ -36,7 +36,7 @@ const Utils = {
try {
const date = new Date(dateString);
return date.toLocaleString('en-US', {
return date.toLocaleString(I18n.locale, {
year: 'numeric',
month: 'short',
day: 'numeric',
@@ -59,7 +59,7 @@ const Utils = {
if (amount === null || amount === undefined) return '-';
try {
return new Intl.NumberFormat('en-US', {
return new Intl.NumberFormat(I18n.locale, {
style: 'currency',
currency: currency
}).format(amount);
@@ -76,7 +76,7 @@ const Utils = {
*/
formatNumber(num) {
if (num === null || num === undefined) return '0';
return num.toLocaleString('en-US');
return num.toLocaleString(I18n.locale);
},
/**