From 4658597a68ec08a1254083b65b64b4879b8e1e3b Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 07:30:41 -0400 Subject: [PATCH 1/9] adding default to config --- next.config.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/next.config.js b/next.config.js index 8eeb73457..f14876174 100644 --- a/next.config.js +++ b/next.config.js @@ -14,6 +14,12 @@ module.exports = { destination: '/interact.html', permanent: false, }, + { + source: '/default/:slug', + destination: '/en/:slug', + permanent: true, + locale: false, + }, { source: '/en/index', destination: '/en', From 348c74826c5669e023bc43d43eb856fa599c422b Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 07:41:28 -0400 Subject: [PATCH 2/9] adding default to config --- next.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index f14876174..cb0247b7a 100644 --- a/next.config.js +++ b/next.config.js @@ -15,8 +15,8 @@ module.exports = { permanent: false, }, { - source: '/default/:slug', - destination: '/en/:slug', + source: '/default/:path*', + destination: '/en/:path*', permanent: true, locale: false, }, From 0d696b4d641b910529b6bcfcc5a56498dae6c981 Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 07:46:33 -0400 Subject: [PATCH 3/9] adding default to config --- next.config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index cb0247b7a..d329203a7 100644 --- a/next.config.js +++ b/next.config.js @@ -4,9 +4,8 @@ module.exports = { defaultLocale: 'default', }, reactStrictMode: true, - // this supposed to work outputStandalone: true, - // . + // async redirects() { return [ { From 79052048562f87706200de1cd6a91d86c21b0bc4 Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 07:54:30 -0400 Subject: [PATCH 4/9] adding default to config --- next.config.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index d329203a7..3945cfb46 100644 --- a/next.config.js +++ b/next.config.js @@ -14,8 +14,32 @@ module.exports = { permanent: false, }, { - source: '/default/:path*', - destination: '/en/:path*', + source: '/default/questions', + destination: '/en/questions', + permanent: true, + locale: false, + }, + { + source: '/default/questions', + destination: '/en/questions', + permanent: true, + locale: false, + }, + { + source: '/default', + destination: '/en', + permanent: true, + locale: false, + }, + { + source: '/default/results', + destination: '/en/results', + permanent: true, + locale: false, + }, + { + source: '/default/404', + destination: '/en/404', permanent: true, locale: false, }, From 48e7b8a9c9fe3b9666c44318c037a00b2337db81 Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 08:10:06 -0400 Subject: [PATCH 5/9] default translations to english --- components/Hooks/index.tsx | 5 +++-- i18n/api/index.ts | 2 ++ next.config.js | 30 ------------------------------ 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/components/Hooks/index.tsx b/components/Hooks/index.tsx index 5cd90433d..2e2c60c25 100644 --- a/components/Hooks/index.tsx +++ b/components/Hooks/index.tsx @@ -42,8 +42,9 @@ export const useWindowWidth = () => { export function useTranslation(key?: string): T { const { locale } = useRouter() + const newLocale = locale === 'default' ? 'en' : locale if (key) { - return webDictionary[locale][key] + return webDictionary[newLocale][key] } - return webDictionary[locale] + return webDictionary[newLocale] } diff --git a/i18n/api/index.ts b/i18n/api/index.ts index 5562284cb..60ab17cb6 100644 --- a/i18n/api/index.ts +++ b/i18n/api/index.ts @@ -146,6 +146,8 @@ export function getTranslations(language: Language): Translations { return apiTranslationsDict.en case Language.FR: return apiTranslationsDict.fr + default: + return apiTranslationsDict.en } } diff --git a/next.config.js b/next.config.js index 3945cfb46..8e9f28c5f 100644 --- a/next.config.js +++ b/next.config.js @@ -13,36 +13,6 @@ module.exports = { destination: '/interact.html', permanent: false, }, - { - source: '/default/questions', - destination: '/en/questions', - permanent: true, - locale: false, - }, - { - source: '/default/questions', - destination: '/en/questions', - permanent: true, - locale: false, - }, - { - source: '/default', - destination: '/en', - permanent: true, - locale: false, - }, - { - source: '/default/results', - destination: '/en/results', - permanent: true, - locale: false, - }, - { - source: '/default/404', - destination: '/en/404', - permanent: true, - locale: false, - }, { source: '/en/index', destination: '/en', From 8685e27b1db5f2e6cc27fe774d1d8e294bbfb5cd Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 08:43:46 -0400 Subject: [PATCH 6/9] default language to english --- components/QuestionsPage/index.tsx | 10 ++++++++-- pages/results/index.tsx | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/QuestionsPage/index.tsx b/components/QuestionsPage/index.tsx index eafafe2b3..237fe957e 100644 --- a/components/QuestionsPage/index.tsx +++ b/components/QuestionsPage/index.tsx @@ -15,7 +15,11 @@ import { } from '../../client-state/InputHelper' import { WebTranslations } from '../../i18n/web' import { BenefitHandler } from '../../utils/api/benefitHandler' -import { Language, MaritalStatus } from '../../utils/api/definitions/enums' +import { + Language, + Language, + MaritalStatus, +} from '../../utils/api/definitions/enums' import { FieldConfig, FieldKey, @@ -59,7 +63,9 @@ export const QuestionsPage: React.VFC = ({}) => { const router = useRouter() const tsln = useTranslation() const isMobile = useMediaQuery(992) - const language = useRouter().locale as Language + + const langx = useRouter().locale as Language + const language = langx === Language.EN || Language.FR ? langx : Language.EN const allFieldConfigs: FieldConfig[] = BenefitHandler.getAllFieldData(language) diff --git a/pages/results/index.tsx b/pages/results/index.tsx index 2d6390678..bc95f3a3d 100644 --- a/pages/results/index.tsx +++ b/pages/results/index.tsx @@ -36,7 +36,9 @@ const Results: NextPage<{ adobeAnalyticsUrl: string }> = ({ (value: FieldInputsObject) => void ] = useSessionStorage('inputs', {}) - const language = useRouter().locale as Language + const langx = useRouter().locale as Language + const language = langx === Language.EN || Language.FR ? langx : Language.EN + const inputHelper = new InputHelper(inputs, setInputs, language) const mainHandler = new MainHandler(inputHelper.asObjectWithLanguage) const response: ResponseSuccess | ResponseError = mainHandler.results From fb0db4f1cef0b4d538af399c7343dabe10cf1b77 Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 08:48:54 -0400 Subject: [PATCH 7/9] default language to english --- components/QuestionsPage/index.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/QuestionsPage/index.tsx b/components/QuestionsPage/index.tsx index 237fe957e..fafcb4f2e 100644 --- a/components/QuestionsPage/index.tsx +++ b/components/QuestionsPage/index.tsx @@ -15,11 +15,7 @@ import { } from '../../client-state/InputHelper' import { WebTranslations } from '../../i18n/web' import { BenefitHandler } from '../../utils/api/benefitHandler' -import { - Language, - Language, - MaritalStatus, -} from '../../utils/api/definitions/enums' +import { Language, MaritalStatus } from '../../utils/api/definitions/enums' import { FieldConfig, FieldKey, From d75f60a74d5ad4377d924d523703afc604b00e08 Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 08:54:12 -0400 Subject: [PATCH 8/9] default language to english --- pages/results/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/results/index.tsx b/pages/results/index.tsx index bc95f3a3d..d68b2803b 100644 --- a/pages/results/index.tsx +++ b/pages/results/index.tsx @@ -37,7 +37,8 @@ const Results: NextPage<{ adobeAnalyticsUrl: string }> = ({ ] = useSessionStorage('inputs', {}) const langx = useRouter().locale as Language - const language = langx === Language.EN || Language.FR ? langx : Language.EN + const language = + langx === Language.EN || langx === Language.FR ? langx : Language.EN const inputHelper = new InputHelper(inputs, setInputs, language) const mainHandler = new MainHandler(inputHelper.asObjectWithLanguage) From e039ee28a52e3babdf742f2fc5d1512516efa216 Mon Sep 17 00:00:00 2001 From: MarcoGoC Date: Fri, 30 Jun 2023 09:00:19 -0400 Subject: [PATCH 9/9] default language to english --- components/QuestionsPage/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/QuestionsPage/index.tsx b/components/QuestionsPage/index.tsx index fafcb4f2e..69cd71e3e 100644 --- a/components/QuestionsPage/index.tsx +++ b/components/QuestionsPage/index.tsx @@ -61,7 +61,8 @@ export const QuestionsPage: React.VFC = ({}) => { const isMobile = useMediaQuery(992) const langx = useRouter().locale as Language - const language = langx === Language.EN || Language.FR ? langx : Language.EN + const language = + langx === Language.EN || langx === Language.FR ? langx : Language.EN const allFieldConfigs: FieldConfig[] = BenefitHandler.getAllFieldData(language)