From 8b106a051f901fde43ecd3ec6bb0d676ffaf7a83 Mon Sep 17 00:00:00 2001 From: Bastyen Date: Tue, 21 May 2024 15:17:30 +0200 Subject: [PATCH] feat: custom translation --- src/i18n/i18n.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/i18n/i18n.ts b/src/i18n/i18n.ts index a62db0ef..7d6840f6 100644 --- a/src/i18n/i18n.ts +++ b/src/i18n/i18n.ts @@ -124,7 +124,7 @@ interface AvailableTranslations { en: Translation; } -export const translate: AvailableTranslations = { +const defaultTranslate: AvailableTranslations = { fr: { filter: 'Filtrer', practice: 'Pratique', @@ -368,3 +368,31 @@ export const translate: AvailableTranslations = { placeholderCategories: 'Select one or more categories', }, }; + +let translate: AvailableTranslations = { ...defaultTranslate }; + +if ((window as any).grwTranslate) { + if ((window as any).grwTranslate.fr) { + translate.fr = { ...defaultTranslate.fr, ...(window as any).grwTranslate.fr }; + translate.fr.home = { ...defaultTranslate.fr.home, ...((window as any).grwTranslate.fr.home ? (window as any).grwTranslate.fr.home : {}) }; + translate.fr.home.segment = { + ...defaultTranslate.fr.home.segment, + ...((window as any).grwTranslate.fr.home && (window as any).grwTranslate.fr.home.segment ? (window as any).grwTranslate.fr.home.segment : {}), + }; + translate.fr.options = { ...defaultTranslate.fr.options, ...((window as any).grwTranslate.fr.options ? (window as any).grwTranslate.fr.options : {}) }; + translate.fr.layers = { ...defaultTranslate.fr.layers, ...((window as any).grwTranslate.fr.layers ? (window as any).grwTranslate.fr.layers : {}) }; + } + + if ((window as any).grwTranslate.en) { + translate.en = { ...defaultTranslate.en, ...(window as any).grwTranslate.en }; + translate.en.home = { ...defaultTranslate.en.home, ...((window as any).grwTranslate.en.home ? (window as any).grwTranslate.en.home : {}) }; + translate.en.home.segment = { + ...defaultTranslate.en.home.segment, + ...((window as any).grwTranslate.en.home && (window as any).grwTranslate.en.home.segment ? (window as any).grwTranslate.en.home.segment : {}), + }; + translate.en.options = { ...defaultTranslate.en.options, ...((window as any).grwTranslate.en.options ? (window as any).grwTranslate.en.options : {}) }; + translate.en.layers = { ...defaultTranslate.en.layers, ...((window as any).grwTranslate.en.layers ? (window as any).grwTranslate.en.layers : {}) }; + } +} + +export { translate };