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(i18n): stub public-facing locales #7288

Merged
merged 4 commits into from
May 16, 2024
Merged

Conversation

LoneRifle
Copy link
Contributor

@LoneRifle LoneRifle commented Apr 25, 2024

Problem

As part of efforts to make it easier to localize FormSG, we are prioritising the public-facing elements of the frontend.

Solution

  • Identify common error messages that a member of the public might see in a form page, and place them in a locale specifically for that.
  • Replace hard-coded text in PublicFormProvider and related components
    with i18next equivalents.

Dropped

The following was initially proposed but subsequently dropped:

  • Default server error messages to i18next keys, and in
    PublicFormProvider, attempt to use them as such. If they are not,
    use the response messages as-is.

This will be addressed in later development work.

Additional work

On request, i18next locales were refactored to be optional, so that
placeholders are no longer needed. en-sg was made mandatory,
since it is a fallback language

  • Allow features within Translation locales to be optional
    • Extend Translation to FallbackTranslation, which still makes them
      mandatory
  • Declare en-sg as a FallbackTranslation
  • Trim zh-sg to only have login translations, removing all other
    placeholder text

Considerations

Even if the frontend and some parts of the backend now refers to our i18next keys, form.server.model defaults
the inactive message to a hard-coded string. Replacing the default with an i18next key is awkward, as the value
will be shown as-is to the form admin, who may be unaware of what we are trying to do.

Identify common error messages that a member of the public might see
in a form page, and place them in a locale specifically for that.

TODO - Move some of the validation messages in common over to this
@LoneRifle LoneRifle requested a review from KenLSM April 25, 2024 01:33
@LoneRifle LoneRifle force-pushed the feat/i18n/public-form-errors branch 2 times, most recently from 01e47a5 to 70ed6f3 Compare April 25, 2024 02:23
@LoneRifle LoneRifle requested a review from karrui May 9, 2024 05:28
karrui
karrui previously requested changes May 10, 2024
frontend/src/i18n/locales/features/public-form/zh-sg.ts Outdated Show resolved Hide resolved
src/app/modules/form/form.errors.ts Outdated Show resolved Hide resolved
@LoneRifle LoneRifle force-pushed the feat/i18n/public-form-errors branch from 70ed6f3 to f639e5e Compare May 13, 2024 00:43
@LoneRifle LoneRifle requested a review from karrui May 13, 2024 00:43
- Replace hard-coded text in PublicFormProvider and related components
  with i18next equivalents
- Default server error messages to i18next keys, and in
  PublicFormProvider, attempt to use them as such. If they are not,
  use the response messages as-is.
Allow translations to be optional, so that development is not
held back by waiting for translations.

Previously, these were required, so either the team waits for
translated text, or is forced to use placeholders. This either slows
the team down, or litters the codebase with unhelpful locale text
to be laboriously translated later.

- Allow features within Translation locales to be optional
  - Extend Translation to FallbackTranslation, which still makes them
    mandatory
- Declare en-sg as a FallbackTranslation
- Trim zh-sg to only have `login` translations, removing all other
  placeholder text
@LoneRifle LoneRifle force-pushed the feat/i18n/public-form-errors branch from f639e5e to ee393b1 Compare May 13, 2024 00:47
Copy link
Contributor

@KenLSM KenLSM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@KenLSM
Copy link
Contributor

KenLSM commented May 15, 2024

Merging develop over to this PR to fix the chromatic issue.

@KenLSM KenLSM enabled auto-merge (squash) May 15, 2024 12:44
@KenLSM KenLSM merged commit aa73ea1 into develop May 16, 2024
16 of 20 checks passed
@KenLSM KenLSM deleted the feat/i18n/public-form-errors branch May 16, 2024 02:01
@KenLSM KenLSM mentioned this pull request May 29, 2024
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.

None yet

3 participants