diff --git a/web/src/components/Editor/EditorCore.tsx b/web/src/components/Editor/EditorCore.tsx index b596914..142103f 100644 --- a/web/src/components/Editor/EditorCore.tsx +++ b/web/src/components/Editor/EditorCore.tsx @@ -1582,6 +1582,7 @@ export function EditorCore({ saved={wordInfo.saved} onToggleSave={toggleSaveWord} pinyin={wordInfo.pinyin} + lang={docLocale(wordInfo.word, docLang)} style={{ top: wordInfo.top, left: wordInfo.left }} onReplace={replaceWord} /> diff --git a/web/src/components/Editor/WordCard.tsx b/web/src/components/Editor/WordCard.tsx index 4649839..a4c6473 100644 --- a/web/src/components/Editor/WordCard.tsx +++ b/web/src/components/Editor/WordCard.tsx @@ -22,11 +22,31 @@ interface Props { // is spelled in letters, and the slashes would say something untrue about it // in the one place a learner is looking for the truth about pronunciation. pinyin?: string + // The locale to pronounce the headword in — the document's language, decided + // by the caller (see docLang in audio/speech.ts). + // + // It has to be passed rather than guessed. `speak` falls back to detecting the + // script, and that test can only tell Han characters from letters: it reads + // "comum" and "casa" as English, so every read-aloud in a Portuguese document + // came out in the English voice. That is the same mistake the "also in" block + // below was built to avoid, arriving through the one button nobody had told + // about the document. + lang?: string style: React.CSSProperties onReplace: (synonym: string) => void } -export function WordCard({ word, info, loading, saved, onToggleSave, pinyin, style, onReplace }: Props) { +export function WordCard({ + word, + info, + loading, + saved, + onToggleSave, + pinyin, + lang, + style, + onReplace, +}: Props) { const t = usePack() const definitions = info?.definitions ?? [] const synonyms = info?.synonyms ?? [] @@ -90,7 +110,7 @@ export function WordCard({ word, info, loading, saved, onToggleSave, pinyin, sty <>