Skip to content

Repository files navigation

XUnity Realtime Translator

中文文档

A realtime XUnity.AutoTranslator endpoint and local configurator for game translation. The endpoint keeps requests single-turn and supports Qwen-MT, DeepSeek Chat Completions, terminology constraints, retries, concurrency limits, and translation-cache alignment.

Screenshots

The screenshots use fictional Example RPG data.

Runtime overview

Model endpoints

Glossary workspace

Features

  • One endpoint ID: RealtimeTranslate.
  • Native Qwen-MT requests with terms and tm_list translation options.
  • A dedicated DeepSeek Chat Completions provider with optional JSON output and disabled thinking for short realtime requests.
  • A glossary for character, place, item, organization, title, skill, and lore terms.
  • Configurable concurrency from 1 to 1024, bounded retries, and a consecutive error limit.
  • Atomic glossary reloads without blocking active translations.
  • TXT terminology extraction and reviewable translation-cache alignment in the configurator.

Installation

Install XUnity.AutoTranslator for the target game first. Download XUnity.RealtimeTranslator.dll and FuzzySharp.dll from the latest Release and copy both files to:

<game directory>/<game>_Data/Managed/Translators/

The endpoint is loaded by XUnity.AutoTranslator and uses these host assemblies from the game's Managed directory:

  • XUnity.AutoTranslator.Plugin.Core.dll
  • Newtonsoft.Json.dll

Usage

Launch the configurator from the repository root when the repository is placed next to the game:

.\LaunchConfigurator.cmd

For a separate repository and game directory:

pyw -3 .\XUnity.RealtimeTranslator.Configurator\configurator.py `
  --game-root 'C:\Games\ExampleRPG'

Use --no-browser to print the local URL without opening a browser. The default port is 17873; override it with --port.

The configurator edits the RealtimeTranslate endpoint and can switch between Qwen-MT and DeepSeek. After saving settings, restart the game so XUnity loads the updated endpoint configuration.

Minimal Qwen-MT settings:

[Service]
Endpoint=RealtimeTranslate

[RealtimeTranslator]
Provider=QwenMT
MaxConcurrency=4
MaxRetries=10
MaxTermsPerRequest=64
UseTerminology=True

[QwenMT]
APIKey=YOUR_QWEN_API_KEY
Model=qwen-mt-flash
BaseUrl=https://dashscope.aliyuncs.com/compatible-mode/v1

For DeepSeek, set Provider=DeepSeekV4 and configure APIKey, BaseUrl, and Model in [DeepSeekV4].

Glossary

The default glossary path is AutoTranslator/QwenMTTerminology.json. It accepts either a JSON array or an object containing a terms array:

[
  {
    "source": "アステリア",
    "target": "阿斯特莉亚",
    "category": "character",
    "enabled": true
  }
]

Add names, places, and items whose spelling must remain stable. The configurator can extract candidates from TXT files and align existing cache entries with enabled glossary targets.

Build

Translator DLL

Build with the .NET SDK and point XUnityReferencesDir at the game's *_Data/Managed directory:

$managed = 'C:\Games\ExampleRPG\ExampleRPG_Data\Managed'
dotnet build '.\XUnity.RealtimeTranslator\XUnity.RealtimeTranslator.csproj' `
  -c Release "-p:XUnityReferencesDir=$managed"

The output is:

XUnity.RealtimeTranslator/bin/Release/net472/XUnity.RealtimeTranslator.dll
XUnity.RealtimeTranslator/bin/Release/net472/FuzzySharp.dll

Configurator frontend

The configurator uses Python 3 at runtime. Build its React/Vite frontend with Node.js and pnpm:

pnpm --dir '.\XUnity.RealtimeTranslator.Configurator\frontend' install
pnpm --dir '.\XUnity.RealtimeTranslator.Configurator\frontend' build

The production files are written to XUnity.RealtimeTranslator.Configurator/web and served by configurator.py.

Checks

py -3 -m unittest discover `
  -s '.\XUnity.RealtimeTranslator.Configurator\tests' -v
pnpm --dir '.\XUnity.RealtimeTranslator.Configurator\frontend' ui-check

ui-check expects a running configurator, Microsoft Edge, and a test game directory.

Repository Layout

XUnity.RealtimeTranslator/
  *.cs                         C# endpoint and runtime helpers
  XUnity.RealtimeTranslator.csproj
XUnity.RealtimeTranslator.Configurator/
  configurator.py              Local HTTP bridge and CLI
  translator_config.py         Config and glossary state
  frontend/                    React/Vite source
  web/                         Production frontend
LaunchConfigurator.cmd   Windows launcher
docs/zh.md                     Chinese documentation
docs/screenshots/              README screenshots

References

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages