Repository navigation
i18n(pt-BR): add Brazilian Portuguese AI and insight locale support - #1251
Conversation
…t flows Add pt-BR locale coverage across medication extraction, coach prose grounding, no-key insight fallbacks, coach read dates, and lab reference range parsing. - Accept pt-BR natively in NaturalLanguageExtractorProps. - Add Brazilian Portuguese population-norm framing patterns. - Add pt-BR no-assessment fallback copy for all insight floors. - Add pt-BR expected date coverage to the Coach read strip test. - Add pt-BR lab range prose vocabulary. - Keep existing locale behavior and safety-contract coverage unchanged.
MBombeck
left a comment
There was a problem hiding this comment.
Thanks a lot for this, @dareoon. The Portuguese reads really well, and the safety and disclaimer copy is careful. A few things keep it from landing yet:
pt-BRisn't registered insrc/lib/i18n/config.ts, so the bundle never loads and theRecord<Locale, …>additions fail typecheck. The Dutch locale (#1246, commit c6f61fa) shows the full set of places a locale needs, includingoutbound-screen.ts(the medication safety patterns), the prompt language files,format-locale.ts,calendar-locale.tsandno-key-fallbacks.ts, which the description mentions but the diff doesn't contain.- The bundle's shape drifts from
en.json: about 420 stray top-level keys duplicated fromsettings,thresholds/gettingStarted/trendHintswrapped in arrays, andselfDescriptionmissing.i18n-locale-integrityfails on this. After rebasing on main, 135 current keys are also missing. - About 35 strings change placeholders (for example
{when}for{date}, dropped{since}/{list}). Severalsettings.integrationCard.*strings look translated from the key name rather than the English text. telegram.helpBodydocumentstomado <nome>, but the bot only acceptstaken <name>.- In
coach-prose-grounding.tsa match exempts a number from grounding.(?:entre|de)\s+…geralmenteand singularmédico … recomendaalso match ordinary sentences about the user's own readings ("Sua pressão de 158/97 geralmente…"), so please narrow them and add a couple of negative cases. - Small wording point: "dose" now stands for both the intake event and the amount. "tomada" for intake would remove the ambiguity.
Happy to help with any of it. If you prefer, I can push the wiring (registration, bundle shape, rebase on main) onto your branch and leave the wording to you. Just say which way you'd like it.
|
@dareoon, a quick heads-up so this doesn't sit around: I'd like Brazilian Portuguese to ship with the next release (1.45), so I'm going to push the wiring onto your branch over the next day or so, the way I offered above:
Your commits stay as they are and the merge keeps them under your name. You'll be credited in the release notes. Your wording stays yours: anything I add is a first draft you're welcome to change, and if you'd rather do some of it yourself, say so here and I'll leave that part to you. |
|
Thanks for the heads-up and for offering to help complete the pt-BR wiring. Please feel free to push the locale registration, bundle restructuring, missing-key updates, and coach safety patterns to the branch. I’ll review the Portuguese wording and linguistic details before the release, especially anything marked for my review. As a native Brazilian Portuguese speaker, I’m happy to refine the copy and ensure the register and phrasing feel natural for Brazilian users. |
|
Brazilian Portuguese is live in v1.45.0, @dareoon. Thank you! Your commits are in under your name. On top of them I registered the locale everywhere, aligned the bundle with the English structure, filled the keys added since you started, used "tomada" for an intake and "dose" for the amount, added Brazil's crisis lines (CVV 188, SAMU 192), and added Portuguese coach safety patterns. One change you should know about: the PHQ-9, GAD-7, WHO-5 and sleep questionnaire items now show their original English wording in pt-BR, because a free translation invalidates the score; if a licensed validated Brazilian version is available, we can switch to it. Anything you'd word differently: the new Translating section in CONTRIBUTING links a browser editor that opens a pull request. |
Summary
Adds Brazilian Portuguese (
pt-BR) support to the medication-extraction and AI insight surfaces, following the AI-initial locale approach used by the Dutch locale PR (#1246).This PR includes the complete
messages/pt-BR.jsonUI translation bundle and focuses on the AI-facing per-locale tables and safety-relevant surfaces that must understand Brazilian Portuguese output.I am a native Brazilian Portuguese speaker and reviewed the Portuguese wording and linguistic details in this change. I also used AI assistance to adapt the existing locale architecture and generate the initial Portuguese patterns/copy; the AI output was reviewed and refined for Brazilian Portuguese usage.
UI bundle
messages/pt-BR.jsonwith Brazilian Portuguese UI translations.Medication extraction
NaturalLanguageExtractorProps.localenow uses the sharedLocaletype, so it acceptspt-BRnatively.MedicationWizardDialogpasses its resolved reader locale directly, without a type cast.Coach prose grounding
Adds Brazilian Portuguese population-norm framing patterns to
coach-prose-grounding.ts, covering common forms such as:Insight fallbacks
Adds Brazilian Portuguese no-AI-key fallback copy for the insight floors in
no-key-fallbacks.ts.Each floor opens with an honest statement that no assessment is available — for example, “Não há avaliação disponível para este cartão no momento.” — and continues with meaning-first guidance rather than clinical instructions.
Tone harness
Adds the pt-BR no-read sentinel to
tone-harness.test.ts:Lab reference ranges
Adds a Brazilian Portuguese entry to
RANGE_PROSEinparse-reference-range.ts, using folded, accent-free forms such as:ate,menos de,abaixo de,maximoa partir de,no minimo,acima de,maior quevalores de referencia,faixa de referenciaCoach read dates
Adds pt-BR expected date coverage to the Coach read strip test.
Test plan
pnpm exec tsc --noEmitsrc/components/insights/derived/__tests__/coach-read-strip-latest-date.test.tsxsrc/lib/insights/eval/__tests__/tone-harness.test.tssrc/lib/insights/__tests__/no-key-fallbacks.test.tssrc/lib/labs/__tests__/parse-reference-range.test.tsoutbound-screensafety tests continue to pass.Reference
This follows the AI-initial locale model of #1246, adapted to the current pt-BR scope.