feat(i18n): add locale query param to opportunity and suggestion GET endpoints | LLMO-5430#2649
Open
Sihalnic-Alin wants to merge 3 commits into
Open
Conversation
…endpoints | LLMO-5430
Add ?locale=<code> support to all opportunity and suggestion read endpoints so
that AI-generated content (title/description on opportunities; title/rationale/
description/actionItems/persona inside suggestion data) can be returned in the
user's selected language once audit workers begin storing translations.
How it works:
- Audit workers store translations in data.i18n[locale] alongside English content
- GET endpoints accept ?locale=fr_fr (or any xx_xx BCP-47 code)
- OpportunityDto promotes i18n[locale].{title,description} to the top-level fields
- SuggestionDto merges i18n[locale] on top of data and strips the i18n key
- Both DTOs strip data.i18n from the response to keep the shape stable
- Missing or absent translations fall back to the original English values
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bb567f2 to
6167fa0
Compare
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.
Changes Made
Adds a
?locale=query parameter to all opportunity and suggestion GET endpoints so that AI-generated content can be returned in the user's selected language once audit workers begin storing translations alongside English content.OpportunityDto:toJSON(oppty, locale)readsdata.i18n[locale]and promotes matchingtitle/descriptionvalues to the top-level response fields; stripsdata.i18nfrom the response so the shape stays stableSuggestionDto:toJSON(suggestion, view, opportunity, locale)mergesdata.i18n[locale]on top of thedataobject (coveringtitle,rationale,description,expectedOutcome,actionItems,persona); stripsdata.i18nfrom the responseOpportunitiesController: all three GET handlers (getAllForSite,getByStatus,getByID) extractlocalefrom query params and pass it to the DTOSuggestionsController: all five GET handlers (getAllForOpportunity,getAllForOpportunityPaged,getByStatus,getByStatusPaged,getByID) extractlocaleand pass it to the DTOparameters.yaml,site-opportunities.yaml): newlocalequery parameter defined with regex^[a-z]{2}_[a-z]{2}$and referenced on all GET opportunity/suggestion endpointstest/dto/opportunity.test.js(8 cases) + 5 locale projection cases added totest/dto/suggestion.test.jsStorage contract for audit workers (Phase 2 — separate PR per worker):
Translations should be stored in
data.i18n[locale]when creating/patching opportunities and suggestions:Missing or absent translations fall back to the original English values — fully non-breaking.
Related Issues
Relates to LLMO-5430
Testing the PR changes
npm test— all 497 tests passcp .env.example .env && npm start)?locale=fr_frand verifytitlereturns the French value:?localeand verify the original Englishtitleis returned (non-breaking)data.i18nis absent from both responsesScreenshots/Videos
No screenshots available.
Additional Notes
N/A