Skip to content

Keep words and word order when repairing translated input names - #1504

Merged
amyjko merged 1 commit into
mainfrom
fix-mention-repair
Nov 15, 2026
Merged

amyjko merged 1 commit into
mainfrom
fix-mention-repair

Conversation

@amyjko

@amyjko amyjko commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Context

After machine translation, repairMentionsPositional (protect.ts) puts back any template input the model mangled. It had two defects, and neither one fails any check, because the result still contains every input and parses fine:

  • It deleted words. It read $name plus any letters after it as one name. In a language written without spaces, $permissionをブロックしたため was "repaired" to $permission, deleting everything up to the next punctuation mark. This affected Japanese heavily, and Chinese and Cantonese wherever an input touched the next word.
  • It swapped inputs. If any one name looked wrong, it rewrote all of them into English order. A translation that had correctly put $lower before $higher came out saying the reverse. This affected every language with a different word order.

Now only the ASCII name the tokenizer reads is treated as the input, and the text after it is kept. A translation that uses exactly the source's names is left alone, whatever their order. Only a name the source doesn't have is replaced, and only in its own position.

The strings already damaged are repaired separately in the locale-repair PR.

Related issues

Verification

  • Four new cases in translate.test.ts: words after a name are kept, a misspelled name is fixed without losing the words after it, reordered inputs are kept, and only the mangled name is repaired, wherever it sits.
  • npm run check:now, npm run test:run.

Checklist

  • Unit tests

🤖 Generated with Claude Code

The mention repair that runs after machine translation read `$name` plus
any letters after it as one mangled name, so in Japanese and Chinese it
deleted the words that follow an input. It also rewrote every input into
English order whenever one name looked wrong, swapping inputs a
translation had correctly reordered. Now only the ASCII name is replaced,
the text after it is kept, and only names the source lacks are repaired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amyjko
amyjko merged commit e48d340 into main Nov 15, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant