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

LF-4400 Add new languages to i18n framework #3409

Merged

Conversation

kathyavini
Copy link
Collaborator

@kathyavini kathyavini commented Sep 4, 2024

Description

This PR adds core support for the four new languages (German, Hindi, Punjabi, and Malayalam) to LiteFarm.

In all places where the new languages could be incorporated without significant refactor, they have been added to this PR. For all other cases, I am opening separate tickets to resolve or investigate. Places where the language codes could be added without refactor are:

  • locales arrays of i18n configuration itself
  • language selection dropdown (now handled by the useLanguageOptions hook, see below)
  • locales switcher of Storybook
  • code that sets up the src/jobs/locales folder for the export server
  • consent forms
  • rc-year-calendar (only available in German; I have created a ticket regarding the other languages)

Additionally:

  • DEFAULT_LANGUAGE & DEFAULT_LANGUAGE_VALUE were intended to refer to the target language, but were instead supplied as translations of "English" in all the contributed languages; I have fixed that here and on CrowdIn and added context on CrowdIn for future contributors

Jira link: https://lite-farm.atlassian.net/browse/LF-4400

Attribution

The framework for this ticket comes from this PR by @mvavrovic (thank you!!!)

Because we are now using the CrowdIn system to normalize and organize translations, the translations portion of that PR was previously uploaded to CrowdIn using this branch:

and the remaining content -- the integregration with app, including the new useLanguageOptions hook -- is now contained within this PR.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

kathyavini and others added 7 commits September 4, 2024 12:06
This commit integrates the useLanguageOptions hook contributed by @mvavrovic in PR #3223 and adds the 3 other new LiteFarm languages to it.

Co-authored-by: mvavrovic <[email protected]>
The other new languages aren't supported by this package
These were meant to be <target-lang>/<lang-code> but were all translated as English :)
@kathyavini kathyavini self-assigned this Sep 4, 2024
@kathyavini kathyavini requested review from a team as code owners September 4, 2024 23:01
@kathyavini kathyavini requested review from Duncan-Brain and removed request for a team September 4, 2024 23:01
@kathyavini kathyavini changed the base branch from integration to patch/translations September 4, 2024 23:02
@antsgar
Copy link
Collaborator

antsgar commented Sep 4, 2024

@kathyavini from yesterday's all team standup, I thought Divya's intention was to be able to release some of the new languages first, even if the others are not ready yet. This patch would actually introduce all the new languages as options to the UI, so we would be releasing all of them or none of them, is that correct? If that's the case you might want to check with her to see if we want to have a "partial" patch ready instead.

@@ -12,7 +12,7 @@ i18n
defaultNS: 'translation',
nsSeparator: ':',
fallbackLng: 'en',
locales: ['en', 'pt', 'es', 'fr'],
locales: ['en', 'pt', 'es', 'fr', 'de', 'hi', 'pa', 'ml'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we get the array of languages here and in the i18next-parser file from the supportedLanguages array? I love how you minimized having to have a list of the languages in a thousand places and thinking if we could extend that further.

@@ -4,7 +4,7 @@ import Backend from 'i18next-fs-backend';
i18n.use(Backend).init(
{
fallbackLng: 'en',
preload: ['en', 'es', 'pt', 'fr'],
preload: ['en', 'es', 'pt', 'fr', 'de', 'hi', 'pa', 'ml'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we have an array of languages somewhere on the api side like you did on webapp, so that we don't have to alter that many files next time we add a new language?

@@ -9,6 +9,7 @@ import { getNewDate } from '../Form/InputDuration/utils';
import 'rc-year-calendar/locales/rc-year-calendar.es';
import 'rc-year-calendar/locales/rc-year-calendar.pt';
import 'rc-year-calendar/locales/rc-year-calendar.fr';
import 'rc-year-calendar/locales/rc-year-calendar.de';
Copy link
Collaborator

@Duncan-Brain Duncan-Brain Sep 5, 2024

Choose a reason for hiding this comment

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

I guess we need a PR to either find a new Calendar package or add these files to our locales then copy them to node_modules to augment package. Thanks for doing that!

Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

Looks great ! Thanks and feel free to merge.

Double thanks to @mvavrovic ! Appreciate your help getting German in and the release to be supported very soon!

@kathyavini kathyavini merged commit 290546e into patch/translations Sep 5, 2024
4 checks passed
@kathyavini
Copy link
Collaborator Author

kathyavini commented Sep 5, 2024

Thank you for both your comments! I've merged so we can start getting QA on the language release ASAP, but we should have time to refine as we prioritize the upcoming language tickets. (Update: ticket now here: LF-4424 Improve efficiency of adding new languages to LiteFarm)

@antsgar as I understood it, Divya was asking us was whether we could start building out the language feature/release without waiting for all the Malayalam translation work to complete. German and Malayalam are the two languages required by our research partners (Hindi and Punjabi were the nice-to-haves) so I don't think actually releasing to prod without Malayalam could ever occur -- although in a pinch I guess we could comment it out if it truly doesn't complete.

Should not be necessary though -- I see progress in CrowdIn for Malayalam now.

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.

3 participants