Repository navigation
String it on Unity: retranslate what XUnity captured with the app's AI - #252
Merged
Merged
Conversation
On Unity games without localization tables String it installs XUnity, which translates with Google instead of the app's AI chain. Pressing String it again on the same game and language now reads every text XUnity captured, translates them in batches with the AI chain (memory, glossary, profile) and writes them to a translation file that XUnity prefers over its own Google output. XUnity's file format was read wrongly: lines were split at the first '=' even when escaped, and multi-line texts reached the AI with literal '\n'. Reading and writing now follow XUnity's own encoding. Checked read-only on the 12,330 lines of the seven XUnity capture files on disk: all read, all rewritten byte for byte. Not yet run end to end from the button, nor looked at in game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Unity games without localization tables, String it installs BepInEx + XUnity, and XUnity translates with Google rather than the app's AI chain. This makes String it a two-step flow:
BepInEx/Translation/{lang}/Text/{Game}.txt. XUnity's README says its own_AutoGeneratedTranslations.txt"will always have the lowest priority", so our file takes precedence. A text the AI does not translate keeps Google's translation. If nothing has been captured yet, the button says to play first.XUnity file format fix
read_captured_translationssplit each line at the first=, escaped or not. That sent multi-line texts to the AI with literal\nsequences.write_translation_filewrote values without encoding them, so a newline in a translation broke the line. Both now follow XUnity's ownTextHelper.Encode/ReadTranslationLineAndDecoderules. This also fixes the existing "Migliora con AI" button, which uses the same two commands.Why two steps and not the live bridge
XUnity sends one text per request, one request at a time, and shuts itself down after five empty responses in a row. Live AI per string would be slow and fragile on free providers. The two-step flow translates in batches of 20 and doesn't need the app running while the game is played. Static extraction before playing wasn't an option either: Mouthwashing keeps its dialogue in
Languages/*.dat, which the game loads at runtime. The full write-up is indocs/METODI-DI-TRADUZIONE.md.Checks
real_xunity_files_round_trip(ignored, read-only) on the 7 XUnity capture files on disk: 12,330 lines, all read, all rewritten byte for byte, none dropped.__tests__/lib/string-it-xunity-ai.test.ts(5 tests). typecheck,i18n:checkand eslint are clean (only pre-existing warnings).Not verified
🤖 Generated with Claude Code