Repository navigation
RedCraftChat 0.2.7-SNAPSHOT
·
4 commits
to master
since this release
Translate messages with clickable parts, keeping every event Interactive messages were always forwarded untranslated, because the pipeline flattens a component tree to legacy text and clicks, hovers and insertions do not survive that. A French player got the menu, in English, rather than a menu whose buttons had quietly died. ComponentTemplate is the NumericTemplate idea applied to subtrees. Every event-carrying subtree is lifted out before serialization and its visible text left inline between paired markers, so one provider call translates the sentence and the button labels together, with full context. The events never travel: they wait on the proxy, keyed by marker name, and are reattached to the translated label afterwards. A provider cannot corrupt a click, because it never sees one, which is also why this beats handing the model the whole component as JSON: that shape sends the events through the model, costs several times the tokens, and fragments the cache. Both marker halves match the placeholder pattern the tokenizing providers already protect, and the Claude prompt names the pair rule. Restore validates string-level: every pair present exactly once, each open before its close, no nesting, no interleaving, nothing foreign. Any violation forwards the original untouched, with a WARN as the canary to watch before the default ever flips. Softer failures degrade per pair: an emptied or swollen label keeps its original words while the sentence translation survives, and a label made of several styled runs lends the sentence its context but is restored verbatim rather than guessing how the translation distributes across the runs. Style survives two ways. The resolved style at each lift point wraps the restored subtree, so a label inheriting gold from its parent is still gold under the style-empty rebuilt root, and click, hover and insertion ride that same wrapper since Adventure keeps all three in Style. Segments after a pair are re-prefixed with the active legacy colour state, because legacy formatting is stateful and the split severed it. Hover-only runs are lifted too, which fixes a latent bug in passing: their hover used to be silently destroyed and replaced by the original-text hover. That hover now attaches to translated segments only, never to a button, so buttons keep their own hover or none. And a message that is nothing but a button becomes translatable for the first time, since its label finally counts as words. upstream-translate-interactive defaults off for exactly one release as a config-only kill switch while it soaks; labels-in-context is the only enabled behaviour, so what soaks is what production will run.