feat: complete Marathi, Tamil and Telugu support and persist the language choice - #1665
Open
Anijesh wants to merge 2 commits into
Open
feat: complete Marathi, Tamil and Telugu support and persist the language choice#1665Anijesh wants to merge 2 commits into
Anijesh wants to merge 2 commits into
Conversation
… choice Locale directories for mr, ta and te already existed, but the feature was not finished: two bundles were unusable, the switcher offered languages that had no translations at all, the choice lived only in localStorage, and Vakil Friend ignored it entirely. Locale bundles: - ta/forms.json and te/forms.json were zero-byte files. i18next could not parse them, so the namespace failed to load and Tamil and Telugu users silently fell back to English with no error surfaced anywhere - Translate the 20 landing-page FAQ keys, absent from all four non-English bundles, plus vakilFriend.connectError and the remaining Hindi gaps - Every bundle now matches English key for key Language switcher: - Add src/config/languages.js as the single source of truth; the landing header and dashboard header each carried their own divergent list - The dashboard header offered gu, kn, bn, ml and pa, none of which have locale files, so choosing one silently left the user in English. They are now shown under "Coming soon" and cannot be selected - Narrow i18next supportedLngs to the languages that actually ship Language preference: - Add preferred_language to ny_user (V54) with GET and PUT /profile/language on the authenticated profile endpoint - Persist on every switch and re-apply at login, so the choice follows the user to a shared computer or a new phone instead of dying with the browser Vakil Friend: - Seed the chat language from the interface language rather than hardcoding English, and follow later switches. Replies are machine-translated by Bhashini per request, so the assistant still covers all ten languages - Replace the duplicated language list and hand-rolled 'xx' + '-IN' speech locale logic with the shared config Tests: - localeCompleteness.test.js holds every shipped language to English key coverage and rejects empty or malformed bundles. Verified it fails when te/forms.json is emptied, which is the bug that shipped unnoticed - 12 cases for the language config, 16 for the backend preference Also restores the AI Summary paragraph in VakilFriendPage and removes a duplicated block in landing/Header.jsx; both files are edited here and both had syntax errors that stopped the frontend compiling. Closes viru0909-dev#1629
|
Someone is attempting to deploy a commit to the CodeBlooded's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Hi @Anijesh, thanks for contributing to Nyay Setu! 🎉 I have automatically:
Our workflows will now analyze your changes to classify:
Tip Ensure your PR description references the issue it resolves (e.g. Happy coding! 🚀 |
WebMvcConfig.addPathPrefix puts every @RestController in the package behind /api/v1, so ProfileController is served at /api/v1/profile, not /profile. The language calls omitted the prefix and would have 404'd. Both callers swallow errors by design, so the switcher would have kept working locally while the preference silently never persisted.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Locale directories for
mr,taandtealready existed onmain, so I started by auditing what actually worked. The bundles were largely written, but the feature was not finished — and two of the failures were invisible at runtime.This PR closes the remaining gaps across all five points in the issue.
Issue Resolved
Closes #1629
What I found first
mainta/forms.jsonandte/forms.jsonwere zero-byte files, and 20 FAQ keys were missing from every non-English bundleChanges Made
1 & 2 — Locale bundles
ta/forms.jsonandte/forms.jsonwere empty files. i18next could not parse them, so the namespace failed to load and Tamil and Telugu users silently got English — no console error, no visible failure.Also translated the 20 landing-page
faq.*keys (missing from all four non-English bundles),vakilFriend.connectError, and the remaining Hindi-only gaps inlitigant.commonandconstitution. Every bundle now matches English key for key.3 — Language switcher
The landing header and the dashboard header each carried their own hardcoded list, and they disagreed: the dashboard offered
gu,kn,bn,mlandpa, none of which have locale files. Picking Kannada left you in English with no explanation.src/config/languages.jsis the single source of truth for both headers,i18n.jsand Vakil Friend.supportedLngsis now derived from the config, so i18next no longer requests bundles that 404.On flags: the issue asks for "flag + language name". I kept the
EN/HI/MR/TA/TEcode badge the landing header already used, because five identical 🇮🇳 flags would distinguish nothing and it matches the existing design. Trivial to switch if you'd rather have literal flags.4 — Language preference on the profile
V54__add_preferred_language_to_ny_user.sqladds a nullablepreferred_language. Null means "never chose one", so existing users keep browser detection.GETandPUT /profile/languageon the existing authenticated/profilecontroller, acting on the signed-in user viaAuthenticationrather than a pathuserId.5 — Vakil Friend
Its language dropdown always started at English, disconnected from the interface language. It now seeds from the UI language and follows later switches.
The assistant still lists all ten languages, and deliberately so: its replies are machine-translated by Bhashini per request rather than read from a locale bundle, so it can converse in languages the interface itself isn't translated into yet. That is a real distinction, and the config models it as two separate capabilities.
Also replaced the duplicated language list and the hand-rolled
'xx' + '-IN'speech-locale logic with the shared config.Tests
src/__tests__/localeCompleteness.test.jsholds every shipped language to English key coverage and rejects empty or malformed bundles. I verified it fails whente/forms.jsonis emptied — it catches exactly the bug that shipped here unnoticed, so the next bundle to drift fails CI instead of quietly degrading for users.How to Test
formsnamespace — it renders Tamil. Onmainthat bundle fails to parse.Testing Completed
npx vitest run— 161 passed, 1 failure inCaseDetailPage.test.jsxthat also fails on a cleanmain(unrelated)mvn test -Dtest=ProfileServiceLanguageTest— 16 passedmain: 27 errors before, 27 after — identical set, all@SpringBootTestcontext loads needing a databasenpm run build— see belowTwo pre-existing syntax errors fixed here
Both are in files this PR already edits, and both stopped the frontend compiling:
litigant/VakilFriendPage.jsx— the AI Summary block lost its paragraph body and closing tag in f7bdcd1, leaving<p>followed directly by</div>. (Same two lines as feat: add frontend input sanitization and length validation for Vakil Friend AI chat #1663; identical change, so the two branches merge cleanly.)landing/Header.jsx—currentPathWithHash,isActiveandbaseStylewere each declared twice.Still blocking
npm run build, left out of scopesrc/pages/judge/RedactionReviewPage.jsxandsrc/pages/lawyer/SemanticSearchPage.jsxboth doimport { api } from '../../services/api', but that module only has a default export. Changing both toimport api from '../../services/api'is the whole fix — with those two lines patched locally, the full production build succeeds, which is how I verified this PR end to end. They have nothing to do with i18n so I left them out; happy to include them or open a separate PR.Separately,
mvnneedscom.networknt:json-schema-validatoradded topom.xmlto compile at all (detailed in #1664), anddb/migrationhas duplicateV51andV52versions, which Flyway rejects. Neither is touched here.Breaking Changes
None. The only user-visible removal is that five languages which previously appeared selectable but silently rendered English are now labelled "Coming soon" — they never worked.
Follow-up worth a separate issue
src/contexts/LanguageContext.jsxis a second, parallel translation system with its own hardcoded English/Hindi dictionary and anen ⇄ hitoggle. The police dashboard pages use it, so those pages can never show Marathi, Tamil or Telugu no matter what this PR does. Migrating them onto i18next is a self-contained follow-up.