diff --git a/frontend/src/features/public-form/components/FormFields/FormSectionsContext.tsx b/frontend/src/features/public-form/components/FormFields/FormSectionsContext.tsx index 0eb17c7875..28ab00a732 100644 --- a/frontend/src/features/public-form/components/FormFields/FormSectionsContext.tsx +++ b/frontend/src/features/public-form/components/FormFields/FormSectionsContext.tsx @@ -10,7 +10,7 @@ import { import { useTranslation } from 'react-i18next' import useScrollSpy from 'react-use-scrollspy' -import { BasicField, FormFieldDto } from '~shared/types' +import { BasicField, FormFieldDto, Language } from '~shared/types' import { FieldIdSet } from '~features/logic/types' import { usePublicFormContext } from '~features/public-form/PublicFormContext' @@ -43,9 +43,17 @@ interface FormSectionsProviderProps { export const FormSectionsProvider = ({ children, }: FormSectionsProviderProps): JSX.Element => { - const { t } = useTranslation() + const { t, i18n } = useTranslation() const { form, isAuthRequired } = usePublicFormContext() + useEffect(() => { + // On page load render, if the form does not support multi-langugage + // set the language preference to be English. + if (!form?.hasMultiLang) { + i18n.changeLanguage(Language.ENGLISH) + } + }, [form?.hasMultiLang, i18n]) + const [visibleFieldIds, setVisibleFieldIds] = useState() const sectionScrollData = useMemo(() => { diff --git a/frontend/src/i18n/locales/features/login/index.ts b/frontend/src/i18n/locales/features/login/index.ts index 4f23d2571e..d32439cc29 100644 --- a/frontend/src/i18n/locales/features/login/index.ts +++ b/frontend/src/i18n/locales/features/login/index.ts @@ -1,5 +1,5 @@ export * from './en-sg' -export * from './zh-sg' +export * from './zh-sg.example' export interface Login { components: { diff --git a/frontend/src/i18n/locales/features/login/zh-sg.ts b/frontend/src/i18n/locales/features/login/zh-sg.example.ts similarity index 100% rename from frontend/src/i18n/locales/features/login/zh-sg.ts rename to frontend/src/i18n/locales/features/login/zh-sg.example.ts diff --git a/frontend/src/i18n/locales/zh-sg.ts b/frontend/src/i18n/locales/zh-sg.ts index ae59977219..d8e892f2b1 100644 --- a/frontend/src/i18n/locales/zh-sg.ts +++ b/frontend/src/i18n/locales/zh-sg.ts @@ -1,6 +1,5 @@ import { PartialDeep } from 'type-fest' -import { zhSG as login } from './features/login' import { zhSG as publicForm } from './features/public-form' import Translation from './types' @@ -8,7 +7,6 @@ export const zhSG: PartialDeep = { translation: { features: { publicForm, - login, }, }, }