Source code for our mod Chat Translator that works via LibreTranslate
| gradle/wrapper | ||
| src/main | ||
| .gitignore | ||
| build.gradle | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| LICENSE | ||
| README.md | ||
| README_RU.md | ||
| settings.gradle | ||
Chat Translator
English | Русский
A NeoForge mod for Minecraft 1.21.1 that automatically translates chat messages so every player sees them in their own language. Powered by LibreTranslate.
Features
- Per-player translation: each recipient gets the message in their configured language
- Works with vanilla clients: they simply see the original text (translation requires the mod on the client)
- Language sources: client locale reported by the mod, vanilla client settings, or automatic detection of the message text (
/detect) - In-game settings GUI (keybind is unbound by default)
- Translation cache with configurable TTL
- Optional "show original" line under the translation
Requirements
| Side | Mod required | Result |
|---|---|---|
| Server + Client | yes | Full translation |
| Server only | server | Players see original messages |
| Client only | client | Does nothing |
- Minecraft 1.21.1
- NeoForge 21.1.x
- A reachable LibreTranslate instance
Installation
- Drop
chattranslator-x.y.z.jarinto themods/folder of your server and/or client. - Make sure a LibreTranslate instance is reachable (see below).
- On the server, edit
config/chattranslator-server.toml:
[server]
enabled = true
libretranslate_url = "http://localhost:5000"
api_key = ""
show_original = true
autodetect_language = false
cache_minutes = 30
request_timeout_ms = 5000
Running LibreTranslate
Self-hosted via Docker:
docker run -p 5000:5000 libretranslate/libretranslate
https://libretranslate.com also works, but requires an API key.
Usage
Open the settings GUI with a configurable keybind (Options → Controls → Key Binds → Chat Translator). From there you can pick your language, test the LibreTranslate connection, and toggle "show original".
Note: the GUI edits the server config, which only takes effect in singleplayer. On dedicated servers use the config file or commands below.
Commands (operators)
| Command | Description |
|---|---|
/chattranslate status |
Show status and current URL |
/chattranslate enable / disable |
Toggle translation globally |
/chattranslate seturl <url> |
Set the LibreTranslate URL |
/chattranslate setkey <key> |
Set the API key |
/chattranslate showoriginal <true|false> |
Toggle original messages under translations |
/chattranslate clearcache |
Clear the translation cache |
Building from source
gradlew build
The jar is written to build/libs/chattranslator-1.0.0.jar.