From e8b1fecb0c54d53380bca3aaab42dba184b0b346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=B6gel?= Date: Fri, 9 Dec 2022 22:04:35 +0100 Subject: [PATCH 1/4] feat: load all dayjs I18n files. --- src/i18n/i18nConfig.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/i18n/i18nConfig.ts b/src/i18n/i18nConfig.ts index f88c72859f..6e64339ce2 100644 --- a/src/i18n/i18nConfig.ts +++ b/src/i18n/i18nConfig.ts @@ -1,6 +1,8 @@ -// dayjs locales must be imported as well +// dayjs locales must be imported as well, list: https://github.com/iamkun/dayjs/tree/dev/src/locale +import "dayjs/locale/it"; import "dayjs/locale/es"; import "dayjs/locale/pt-br"; +import "dayjs/locale/sv"; import i18n from "i18next"; import LanguageDetector from "i18next-browser-languagedetector"; import { initReactI18next } from "react-i18next"; From b20710a26002395b3c8816e41625752d6c7452ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=B6gel?= Date: Fri, 9 Dec 2022 22:08:12 +0100 Subject: [PATCH 2/4] refactor: toLowerCase should be what we want here. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit toLocaleLowercase is used to lowercase Turkish "İstanbul", e.g. Locale names should all be in ASCII, however. --- src/app/context/SettingsContext.tsx | 2 +- src/common/utils/currencyConvert.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/context/SettingsContext.tsx b/src/app/context/SettingsContext.tsx index a54107f3c0..02e24c4b89 100644 --- a/src/app/context/SettingsContext.tsx +++ b/src/app/context/SettingsContext.tsx @@ -113,7 +113,7 @@ export const SettingsProvider = ({ // need to switch i.e. `pt_BR` to `pt-br` const daysjsLocaleFormatted = settings.locale - .toLocaleLowerCase() + .toLowerCase() .replace("_", "-"); dayjs.locale(daysjsLocaleFormatted); }, [settings.locale]); diff --git a/src/common/utils/currencyConvert.ts b/src/common/utils/currencyConvert.ts index a460f86f44..9e836fd7f4 100644 --- a/src/common/utils/currencyConvert.ts +++ b/src/common/utils/currencyConvert.ts @@ -13,7 +13,7 @@ export const getFormattedFiat = (params: { }) => { const fiatValue = Number(params.amount) * params.rate; - const l = (params.locale || "en").toLocaleLowerCase().replace("_", "-"); + const l = (params.locale || "en").toLowerCase().replace("_", "-"); return new Intl.NumberFormat(l || "en", { style: "currency", currency: params.currency, @@ -24,7 +24,7 @@ export const getFormattedNumber = (params: { amount: number | string; locale: string; }) => { - const l = (params.locale || "en").toLocaleLowerCase().replace("_", "-"); + const l = (params.locale || "en").toLowerCase().replace("_", "-"); return new Intl.NumberFormat(l || "en").format(Number(params.amount)); }; From 4f95ef574309b8fd2db30ce00331956e371be6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=B6gel?= Date: Fri, 9 Dec 2022 22:08:31 +0100 Subject: [PATCH 3/4] refactor: ABC. --- src/i18n/i18nConfig.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/i18n/i18nConfig.ts b/src/i18n/i18nConfig.ts index 6e64339ce2..41b2334003 100644 --- a/src/i18n/i18nConfig.ts +++ b/src/i18n/i18nConfig.ts @@ -26,6 +26,11 @@ export const resources = { common: es.common, components: es.components, }, + it: { + translation: it.translation, + common: it.common, + components: it.components, + }, "pt-BR": { translation: pt_BR.translation, common: pt_BR.common, @@ -36,20 +41,15 @@ export const resources = { common: sv.common, components: sv.components, }, - it: { - translation: it.translation, - common: it.common, - components: it.components, - }, } as const; // needs to be aligned with `resources` export const supportedLocales = [ { locale: "en", label: "English" }, { locale: "es", label: "Español" }, + { locale: "it", label: "Italiano" }, { locale: "pt-BR", label: "Português (Brasil)" }, { locale: "sv", label: "Svenska" }, - { locale: "it", label: "Italiano" }, ]; i18n From 6a04000bc1d20c7940902c182a0a395424a798d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=B6gel?= Date: Fri, 9 Dec 2022 22:16:24 +0100 Subject: [PATCH 4/4] refactor: ABC again!? --- src/i18n/i18nConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/i18nConfig.ts b/src/i18n/i18nConfig.ts index 41b2334003..002daf2653 100644 --- a/src/i18n/i18nConfig.ts +++ b/src/i18n/i18nConfig.ts @@ -1,6 +1,6 @@ // dayjs locales must be imported as well, list: https://github.com/iamkun/dayjs/tree/dev/src/locale -import "dayjs/locale/it"; import "dayjs/locale/es"; +import "dayjs/locale/it"; import "dayjs/locale/pt-br"; import "dayjs/locale/sv"; import i18n from "i18next";