1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Format locale to Intl standard for translated date in notifications. (#11036)

* Format locale to Intl standard for translated date in notifications.

* Simplify logic for correctly formatting locale code for Intl

* Numeric format dates

Co-authored-by: Dan Miller <danjm.com@gmail.com>
This commit is contained in:
Thomas Huang 2021-05-11 09:25:09 -07:00 committed by GitHub
parent 2289e47e87
commit 1338b2f8ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,17 +16,18 @@ export const UI_NOTIFICATIONS = {
}, },
3: { 3: {
id: 3, id: 3,
date: '2021-03-8', date: '2021-03-08',
}, },
}; };
export const getTranslatedUINoficiations = (t, locale) => { export const getTranslatedUINoficiations = (t, locale) => {
const formattedLocale = locale.replace('_', '-');
return { return {
1: { 1: {
...UI_NOTIFICATIONS[1], ...UI_NOTIFICATIONS[1],
title: t('notifications1Title'), title: t('notifications1Title'),
description: t('notifications1Description'), description: t('notifications1Description'),
date: new Intl.DateTimeFormat(locale).format( date: new Intl.DateTimeFormat(formattedLocale).format(
new Date(UI_NOTIFICATIONS[1].date), new Date(UI_NOTIFICATIONS[1].date),
), ),
}, },
@ -35,7 +36,7 @@ export const getTranslatedUINoficiations = (t, locale) => {
title: t('notifications2Title'), title: t('notifications2Title'),
description: t('notifications2Description'), description: t('notifications2Description'),
actionText: t('notifications2ActionText'), actionText: t('notifications2ActionText'),
date: new Intl.DateTimeFormat(locale).format( date: new Intl.DateTimeFormat(formattedLocale).format(
new Date(UI_NOTIFICATIONS[2].date), new Date(UI_NOTIFICATIONS[2].date),
), ),
}, },
@ -44,7 +45,7 @@ export const getTranslatedUINoficiations = (t, locale) => {
title: t('notifications3Title'), title: t('notifications3Title'),
description: t('notifications3Description'), description: t('notifications3Description'),
actionText: t('notifications3ActionText'), actionText: t('notifications3ActionText'),
date: new Intl.DateTimeFormat(locale).format( date: new Intl.DateTimeFormat(formattedLocale).format(
new Date(UI_NOTIFICATIONS[3].date), new Date(UI_NOTIFICATIONS[3].date),
), ),
}, },