Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only show fixed translations for supported forms #8038

Merged
merged 2 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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<FieldIdSet>()

const sectionScrollData = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/features/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './en-sg'
export * from './zh-sg'
export * from './zh-sg.example'

export interface Login {
components: {
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/i18n/locales/zh-sg.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { PartialDeep } from 'type-fest'

import { zhSG as login } from './features/login'
import { zhSG as publicForm } from './features/public-form'
import Translation from './types'

export const zhSG: PartialDeep<Translation> = {
translation: {
features: {
publicForm,
login,
},
},
}
Loading