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

feat: multi lang feature #8022

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

siddarth2824
Copy link
Collaborator

@siddarth2824 siddarth2824 commented Dec 29, 2024

Problem

  • Currently form admins deal with multiple languages in various ways, each of these ways have their cons to both the form filler and the admin:
    • Everything in one form:
      • A very bad experience for the form filler
    • Toggling language by logic:
      • Difficult for form admins to manage logic, can get messy if form is long
    • Individual forms for each language:
      • Difficult for form admin to manage 4 links and consolidate responses from 4 separate forms

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
    • Details ...
  • No - this PR is backwards compatible

Before & After Screenshots

  • The before & after screenshots can be seen in the above sub PRs.

siddarth2824 and others added 5 commits December 16, 2024 09:06
* feat: add fields in model to represent translations for form fields

* feat: add shared types to represent form field translations

* fix: use unicode locales
* feat: add settings tab and toggle for multi lang feature

* feat: add fields to joi validations

* fix: refactor code to address comments

* fix: failing tests

* feat: add tooltip over icons

* feat: add chromatic tests
* feat: add model fields to represent translations for form fields (#7457)

* feat: add fields in model to represent translations for form fields

* feat: add shared types to represent form field translations

* fix: use unicode locales

* feat: add settings tab and toggle for multi lang feature (#7561)

* feat: add settings tab and toggle for multi lang feature

* feat: add fields to joi validations

* fix: refactor code to address comments

* fix: failing tests

* feat: add tooltip over icons

* feat: add chromatic tests

* feat: add view to list form fields for translation

* feat: update logic for checking completion of translations and add storybook tests

* chore: uncomment growthbook middleware usage

* chore: update storybook function used

* chore: address comments

* chore: update app router
* feat: add view for translation input

* fix: refactor code and remove console log statements

* chore: clean up code

* chore: fix alignment of translation input and header

* chore: address comments
* feat: add model fields to represent translations for form fields (#7457)

* feat: add fields in model to represent translations for form fields

* feat: add shared types to represent form field translations

* fix: use unicode locales

* feat: add settings tab and toggle for multi lang feature (#7561)

* feat: add settings tab and toggle for multi lang feature

* feat: add fields to joi validations

* fix: refactor code to address comments

* fix: failing tests

* feat: add tooltip over icons

* feat: add chromatic tests

* feat: add translations on public form

* fix: missing provider values for preview and template providers

* feat: add fixed translations for yes and no field

* chore: fix code

* chore: remove unused code and add import

* feat: add fixed translations for est time taken string

* chore: remove unnecessary loggin

* feat: add translations for verifiable fields

* chore: fix tests

* feat: add error if user adds less than required translations for form fields with options

* feat: add beta flag for multi language translation feature for admins

* chore: refactor code

* feat: add fixed translations for default placeholders on public form

* feat: add fixed translations for not found label

* feat: add translations for maximum file size label

* feat: add translations for others label

* feat: add fixed translations for add row label

* feat: add translation for prevent submission messages

* fix: make prevent submission translations optional

* fix: tests

* refactor: use i18next to toggle languages

Use i18next to hold currently selected language rather than use our own
internal state flag in PublicFormContext. That way, a form submitter
can control the language used across the entire Form service.

- Rework LanguageControl and PublicFormContext to use i18next to hold
  currently selected language, falling back on `Language.ENGLISH`
- Rework components to lookup current lang from `useTranslation()`, not
  `PublicFormContext.selectedPublicFormLanguage` or prop passing

* fix: stub i18next for YesNo,Email,Verify fields

* refactor(i18n): move translations from `fixedTranslations`

* refactor(i18n): extract hard-coded translations

* feat: add title translations for MyInfo fields

* feat: always default language back to English on CreatePage

* fix: update myInfo translations and address comments

* feat: add custom header to track user selected form language

---------

Co-authored-by: LoneRifle <[email protected]>
@datadog-opengovsg
Copy link

Datadog Report

Branch report: feat/multi-lang-feature
Commit report: 4cf742d
Test service: formsg

✅ 0 Failed, 2168 Passed, 1 Skipped, 5m 3.95s Total duration (1m 59.13s time saved)

@siddarth2824 siddarth2824 changed the title Feat/multi lang feature feat: multi lang feature Dec 29, 2024
@siddarth2824 siddarth2824 marked this pull request as ready for review January 2, 2025 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant