diff --git a/app/modules/loyalty/static/shared/js/loyalty-card-detail-view.js b/app/modules/loyalty/static/shared/js/loyalty-card-detail-view.js index 2b8b541c..941162a9 100644 --- a/app/modules/loyalty/static/shared/js/loyalty-card-detail-view.js +++ b/app/modules/loyalty/static/shared/js/loyalty-card-detail-view.js @@ -177,13 +177,13 @@ function loyaltyCardDetailView(config) { // Formatting helpers formatNumber(num) { - return num == null ? '0' : new Intl.NumberFormat('en-US').format(num); + return num == null ? '0' : new Intl.NumberFormat(I18n.locale).format(num); }, formatDate(dateString) { if (!dateString) return 'Never'; try { - return new Date(dateString).toLocaleDateString('en-US', { + return new Date(dateString).toLocaleDateString(I18n.locale, { year: 'numeric', month: 'short', day: 'numeric' @@ -196,7 +196,7 @@ function loyaltyCardDetailView(config) { formatDateTime(dateString) { if (!dateString) return 'Never'; try { - return new Date(dateString).toLocaleString('en-US', { + return new Date(dateString).toLocaleString(I18n.locale, { year: 'numeric', month: 'short', day: 'numeric', diff --git a/app/modules/loyalty/static/shared/js/loyalty-cards-list.js b/app/modules/loyalty/static/shared/js/loyalty-cards-list.js index 8454a9c2..c6bf19fb 100644 --- a/app/modules/loyalty/static/shared/js/loyalty-cards-list.js +++ b/app/modules/loyalty/static/shared/js/loyalty-cards-list.js @@ -223,13 +223,13 @@ function loyaltyCardsList(config) { // Formatting helpers formatNumber(num) { - return num == null ? '0' : new Intl.NumberFormat('en-US').format(num); + return num == null ? '0' : new Intl.NumberFormat(I18n.locale).format(num); }, formatDate(dateString) { if (!dateString) return 'Never'; try { - return new Date(dateString).toLocaleDateString('en-US', { + return new Date(dateString).toLocaleDateString(I18n.locale, { year: 'numeric', month: 'short', day: 'numeric' diff --git a/app/modules/loyalty/static/shared/js/loyalty-devices-list.js b/app/modules/loyalty/static/shared/js/loyalty-devices-list.js index 2c331ba0..765f7ee6 100644 --- a/app/modules/loyalty/static/shared/js/loyalty-devices-list.js +++ b/app/modules/loyalty/static/shared/js/loyalty-devices-list.js @@ -110,7 +110,7 @@ function loyaltyDevicesList(config) { formatDate(value) { if (!value) return '-'; try { - return new Date(value).toLocaleString(); + return new Date(value).toLocaleString(I18n.locale); } catch (e) { return value; } diff --git a/app/modules/loyalty/static/shared/js/loyalty-pins-list.js b/app/modules/loyalty/static/shared/js/loyalty-pins-list.js index 585d8bab..f644fada 100644 --- a/app/modules/loyalty/static/shared/js/loyalty-pins-list.js +++ b/app/modules/loyalty/static/shared/js/loyalty-pins-list.js @@ -317,7 +317,7 @@ function loyaltyPinsList(config) { formatDate(dateString) { if (!dateString) return 'Never'; try { - return new Date(dateString).toLocaleDateString('en-US', { + return new Date(dateString).toLocaleDateString(I18n.locale, { year: 'numeric', month: 'short', day: 'numeric' @@ -330,7 +330,7 @@ function loyaltyPinsList(config) { formatDateTime(dateString) { if (!dateString) return 'Never'; try { - return new Date(dateString).toLocaleDateString('en-US', { + return new Date(dateString).toLocaleString(I18n.locale, { year: 'numeric', month: 'short', day: 'numeric', diff --git a/app/modules/loyalty/static/shared/js/loyalty-transactions-list.js b/app/modules/loyalty/static/shared/js/loyalty-transactions-list.js index c3a83d03..74fac64a 100644 --- a/app/modules/loyalty/static/shared/js/loyalty-transactions-list.js +++ b/app/modules/loyalty/static/shared/js/loyalty-transactions-list.js @@ -209,13 +209,13 @@ function loyaltyTransactionsList(config) { // Formatting helpers formatNumber(num) { - return num == null ? '0' : new Intl.NumberFormat('en-US').format(num); + return num == null ? '0' : new Intl.NumberFormat(I18n.locale).format(num); }, formatDate(dateString) { if (!dateString) return 'Never'; try { - return new Date(dateString).toLocaleDateString('en-US', { + return new Date(dateString).toLocaleDateString(I18n.locale, { year: 'numeric', month: 'short', day: 'numeric' @@ -228,7 +228,7 @@ function loyaltyTransactionsList(config) { formatDateTime(dateString) { if (!dateString) return 'Never'; try { - return new Date(dateString).toLocaleDateString('en-US', { + return new Date(dateString).toLocaleString(I18n.locale, { year: 'numeric', month: 'short', day: 'numeric', diff --git a/static/shared/js/i18n.js b/static/shared/js/i18n.js index ff8ae793..21437459 100644 --- a/static/shared/js/i18n.js +++ b/static/shared/js/i18n.js @@ -170,6 +170,16 @@ const I18n = { } }, + /** + * BCP-47 locale tag for the current dashboard language. + * Use as the first arg to Intl.* / toLocale* APIs so dates and numbers + * render in the user's language instead of the browser default. + * Falls back to 'en' (which is what the dashboards default to). + */ + get locale() { + return this._language || 'en'; + }, + /** * Notify Alpine (and other listeners) that translations are ready. * Bumps the Alpine store version so reactive $t() bindings re-evaluate.