Support for real-time translations in Matrix chats
- Python 100%
| chat_translate | ||
| docs/00-init | ||
| tests | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| AGENTS.md | ||
| config.example.yaml | ||
| main.py | ||
| pytest.ini | ||
| README.md | ||
| requirements.txt | ||
chat-translate
A Python bot that joins Matrix rooms and provides real-time message translation.
Features
- Registers on an arbitrary number of Matrix rooms.
- Configurable target language per room or per user.
- Language resolution order: user override → room default → skip.
- Replies in-thread to the original message with the translated text.
- Auto-detects source language.
- Supports end-to-end encrypted (E2EE) rooms when
libolmandpython-olmare available.
Quick Start
1. Install dependencies
pip install -r requirements.txt
For E2EE support (encrypted rooms), you also need libolm installed on your
system (e.g. pacman -S libolm python-olm on Arch, apt install libolm-dev
on Debian/Ubuntu).
2. Configure
Copy the example configuration and edit it:
cp config.example.yaml config.yaml
3. Run
python main.py -c config.yaml
Use -v for verbose/debug logging.
Configuration Reference
matrix:
homeserver: https://matrix.example.com
user_id: "@translate-bot:example.com"
password: "s3cret"
# OR use an access token instead of password:
# access_token: "syt_..."
rooms:
"!roomid1:example.com":
language: en # default target language for the room
users:
"@alice:example.com":
language: it # per-user override
"@bob:example.com":
language: de
"!roomid2:example.com":
language: fr
Fields
| Field | Required | Description |
|---|---|---|
matrix.homeserver |
Yes | Matrix homeserver URL |
matrix.user_id |
Yes | Bot's Matrix user ID |
matrix.device_id |
No** | Device ID (required when using access_token) |
matrix.password |
No* | Bot account password |
matrix.access_token |
No* | Pre-existing access token |
matrix.store_path |
No | Directory to persist encryption keys (default: store) |
rooms.<room_id>.language |
No | Default target language for the room |
rooms.<room_id>.users.<user_id>.language |
No | Target language override for a specific user |
* Either password or access_token must be provided.
Development
# Install dev dependencies
pip install -r requirements.txt
# Run tests
pytest
# Run linters
pre-commit run --all-files
License
MIT