Skip to content

Commit

Permalink
Merge pull request #797 from DTS-STN/i18n-hotfix
Browse files Browse the repository at this point in the history
i18n - adding default to config
  • Loading branch information
MarcoGoC authored Jun 30, 2023
2 parents abbb5b8 + e039ee2 commit fafccdc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
5 changes: 3 additions & 2 deletions components/Hooks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ export const useWindowWidth = () => {

export function useTranslation<T = string | WebTranslations>(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]
}
5 changes: 4 additions & 1 deletion components/QuestionsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export const QuestionsPage: React.VFC = ({}) => {
const router = useRouter()
const tsln = useTranslation<WebTranslations>()
const isMobile = useMediaQuery(992)
const language = useRouter().locale as Language

const langx = useRouter().locale as Language
const language =
langx === Language.EN || langx === Language.FR ? langx : Language.EN

const allFieldConfigs: FieldConfig[] =
BenefitHandler.getAllFieldData(language)
Expand Down
2 changes: 2 additions & 0 deletions i18n/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export function getTranslations(language: Language): Translations {
return apiTranslationsDict.en
case Language.FR:
return apiTranslationsDict.fr
default:
return apiTranslationsDict.en
}
}

Expand Down
3 changes: 1 addition & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ module.exports = {
defaultLocale: 'default',
},
reactStrictMode: true,
// this supposed to work
outputStandalone: true,
// .
//
async redirects() {
return [
{
Expand Down
5 changes: 4 additions & 1 deletion pages/results/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ 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 || langx === Language.FR ? langx : Language.EN

const inputHelper = new InputHelper(inputs, setInputs, language)
const mainHandler = new MainHandler(inputHelper.asObjectWithLanguage)
const response: ResponseSuccess | ResponseError = mainHandler.results
Expand Down

0 comments on commit fafccdc

Please sign in to comment.