mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
feat(i18n): add Brazilian Portuguese support to medication and insight 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.
This commit is contained in:
1 parent
da3edbf729
commit
12065bc0c7
5 files changed
+37
-1
No files matched your search
@@ -91,6 +91,7 @@ describe("CoachReadStrip — the latest reading's day", () => {
|
||||
it: "1 ottobre",
|
||||
ko: "10월 1일",
|
||||
pl: "1 października",
|
||||
"pt-BR": "1 de outubro",
|
||||
};
|
||||
for (const [locale, date] of Object.entries(expected) as Array<
|
||||
[Locale, string]
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
* button is the open-trigger.
|
||||
*/
|
||||
|
||||
import type { Locale } from "@/lib/i18n/config";
|
||||
import { useCallback, useId, useRef, useState } from "react";
|
||||
import { Loader2, Sparkles } from "lucide-react";
|
||||
|
||||
@@ -72,7 +73,7 @@ export interface NaturalLanguageExtractorProps {
|
||||
* UI locale forwarded to the route as a hint. The route accepts an
|
||||
* undefined value and falls back to the resolver chain.
|
||||
*/
|
||||
locale?: "en" | "de" | "es" | "fr" | "it" | "pl" | "ko";
|
||||
locale?: Locale;
|
||||
/**
|
||||
* Optional override of the API path so the wizard test harness can
|
||||
* point at a mock server. Defaults to the production route.
|
||||
|
||||
@@ -870,6 +870,15 @@ const POPULATION_NORM_PATTERNS: Record<Locale, readonly RegExp[]> = {
|
||||
], // No `\b` next to Hangul (it is an ASCII \w boundary), and the object sits
|
||||
// between subject and verb in Korean, so each entry allows a gap where the
|
||||
// Latin banks put \s+.
|
||||
"pt-BR": [
|
||||
/\bfaixa\s+(?:de\s+refer[eê]ncia|normal)\b/i,
|
||||
/\bvalor(?:es)?\s+de\s+refer[eê]ncia\b/i,
|
||||
/\b(?:adultos?|pessoas?)\s+saud[áa]ve(?:l|is)\b/i,
|
||||
/\bmaioria\s+(?:dos\s+)?(?:adultos?|das\s+pessoas)\b/i,
|
||||
/\b(?:diretrizes|guias|m[eé]dicos?|especialistas?)\b[^.?!]{0,30}\b(?:recomend(?:am|a)|suger(?:em|e)|indic(?:am|a))\b/i,
|
||||
/\b(?:adultos?|pessoas?)\b[^.?!]{0,30}\b(?:geralmente|normalmente|em\s+geral)\b[^.?!]{0,30}\b(?:precis(?:am|a)|devem|necessit(?:am|a))\b/i,
|
||||
/\b(?:entre|de)\s+[^.?!]{0,30}\b(?:normalmente|geralmente|em\s+geral)\b/i,
|
||||
],
|
||||
ko: [
|
||||
/정상\s*범위(?:는|가|를|로|의)/,
|
||||
/(?:참고|기준|권장)\s*(?:범위|치|값)/,
|
||||
|
||||
@@ -254,6 +254,7 @@ describe("tone harness — deterministic fallbacks", () => {
|
||||
es: /no hay ninguna valoración/,
|
||||
it: /non è disponibile alcuna valutazione/,
|
||||
pl: /nie ma (?:tu )?żadnej oceny/,
|
||||
"pt-BR": /n[aã]o h[áa] (?:uma )?avalia[çc][aã]o/i,
|
||||
ko: /평가가 없어요/,
|
||||
};
|
||||
|
||||
|
||||
@@ -263,6 +263,30 @@ export const RANGE_PROSE: Record<Locale, RangeProse> = {
|
||||
// matchers here are prefix-anchored, so only the prefix-shaped notation is
|
||||
// listed. A postfixed Korean range still falls through to text-only, which
|
||||
// `isUnreadableRange` reports rather than hides.
|
||||
"pt-BR": {
|
||||
twoSided: ["a", "e"],
|
||||
upper: [
|
||||
"ate",
|
||||
"menos de",
|
||||
"abaixo de",
|
||||
"inferior a",
|
||||
"maximo",
|
||||
"no maximo",
|
||||
],
|
||||
lower: [
|
||||
"a partir de",
|
||||
"no minimo",
|
||||
"minimo",
|
||||
"acima de",
|
||||
"maior que",
|
||||
"maior de",
|
||||
],
|
||||
filler: [
|
||||
"valores de referencia",
|
||||
"valor de referencia",
|
||||
"faixa de referencia",
|
||||
],
|
||||
},
|
||||
ko: {
|
||||
twoSided: ["에서", "부터"],
|
||||
upper: ["최대", "최고"],
|
||||
|
||||
Reference in new issue
Block a user