The advice arrived in the language she was trying to read her way out of
Reported as "the Portuguese option isn't translating the advice in English — it's just reprinting Portuguese." Nothing was wrong with targetFor. It was reading a direction the account could not leave. learnerPairs held only zh, so SetPair refused learning_pair for pt-PT and every Portuguese account was learning_en by force. targetFor then did exactly what it says: explanations follow the half of the pair she is not learning, which for a forced learning_en account is Portuguese. A Portuguese document, corrected in Portuguese, explained in Portuguese, with no way to ask for English — correct behaviour derived from a fact about the roster that was no longer true. The note in learnerPairs was written one phase too early to see it. It said turning a pair around needs a word list and a dictionary reading into English, and that fr, es and pt-PT had neither. Portuguese has both. Word boundaries are spaces — the megabyte jieba needs is a property of a writing system that doesn't use them, not a debt every pair owes. And the dictionary arrived with dict.db, which reads pt→en as readily as en→pt; dreamProvider.reverse has been answering that question since the pair shipped. What was actually blocking the pair a native English speaker learning Portuguese needs was this list. So pt-PT joins it, and the pt-PT pack gets the learner copy the control renders from — each label in the language of whoever would pick it, since someone on the wrong side of that switch cannot read the side they are reaching for. fr and es clear the same two bars through the same dict.db and stay out: their packs carry no learner block yet, which is a translation question rather than a data one, and the server should keep saying no until one is written. Two things that assumed learning_pair meant Chinese, now that it doesn't. The segmenter gate reads the pair as well as the direction, or a Portuguese learner would load a megabyte of Chinese word list and hover Portuguese words at /api/hanzi. And that endpoint's own comment justified skipping providerFor with a guarantee it no longer has; the real guarantee was always the caller's — it is only ever asked about tokens the Chinese segmenter found — and a stray lookup was already safe, answering a miss with an empty 200. Tests in both packages. The auth test that pinned pt-PT's refusal now pins its acceptance, with fr and es still refused; the suggestions test pins the consequence where it actually lands, which is the language she reads her advice in. Claude-Session: https://claude.ai/code/session_01GJHNvirh7Hzhc9RL3HAvz7
This commit is contained in:
@@ -119,8 +119,36 @@ func TestDocumentLangNeedsCorroboration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The two language decisions are genuinely independent, and only the zh pair can
|
||||
// prove it today — it is the one pair that can be travelled in both directions.
|
||||
// The Portuguese half of the same rule, and the bug it was reported as: "the
|
||||
// Portuguese option isn't translating the advice in English — it's just
|
||||
// reprinting Portuguese."
|
||||
//
|
||||
// Nothing was wrong with targetFor when that was reported. It was reading a
|
||||
// direction the account could not leave: `learnerPairs` held only zh, so every
|
||||
// pt-PT writer was learning_en by force and this function correctly explained a
|
||||
// Portuguese document in Portuguese. Pinned here rather than only in the auth
|
||||
// package because this is where the consequence actually lands — the language
|
||||
// the writer reads her advice in.
|
||||
func TestTargetExplainsPortugueseInEnglishForALearner(t *testing.T) {
|
||||
learner := targetFor("pt-PT", auth.DirectionLearningPair, docLangPair)
|
||||
if learner.Correct.Code != "pt-PT" {
|
||||
t.Fatalf("corrected in %s, want the document's own Portuguese", learner.Correct.Code)
|
||||
}
|
||||
if learner.Explain.Code != "en" {
|
||||
t.Fatalf("explained in %s, want English", learner.Explain.Code)
|
||||
}
|
||||
|
||||
// And the native Portuguese speaker practising English is untouched: her
|
||||
// Portuguese is still explained in Portuguese.
|
||||
native := targetFor("pt-PT", auth.DirectionLearningEn, docLangPair)
|
||||
if native.Correct.Code != "pt-PT" || native.Explain.Code != "pt-PT" {
|
||||
t.Fatalf("learning_en on a Portuguese document: correct=%s explain=%s", native.Correct.Code, native.Explain.Code)
|
||||
}
|
||||
}
|
||||
|
||||
// The two language decisions are genuinely independent, and zh was the first
|
||||
// pair that could prove it — the first that could be travelled in both
|
||||
// directions.
|
||||
//
|
||||
// A Mandarin native practising English who writes Chinese wants Chinese
|
||||
// corrections explained in Chinese. An English native learning Chinese who writes
|
||||
|
||||
Reference in New Issue
Block a user