Support for real-time translations in Matrix chats
Find a file
2026-05-14 04:25:25 +02:00
chat_translate fix: sync before join to ensure rooms are in local state 2026-05-14 04:25:25 +02:00
docs/00-init feat: initialize chat-translate project 2026-05-14 01:33:23 +02:00
tests fix(encryption): Properly initialize crypto store via restore_login 2026-05-14 02:25:21 +02:00
.gitignore chore(gitignore): Add config.yaml 2026-05-14 01:36:33 +02:00
.pre-commit-config.yaml feat: initialize chat-translate project 2026-05-14 01:33:23 +02:00
AGENTS.md feat: initialize chat-translate project 2026-05-14 01:33:23 +02:00
config.example.yaml fix(encryption): Properly initialize crypto store via restore_login 2026-05-14 02:25:21 +02:00
main.py chore(logging): Set nio.responses logging level to ERROR 2026-05-14 04:10:34 +02:00
pytest.ini feat: initialize chat-translate project 2026-05-14 01:33:23 +02:00
README.md fix(encryption): Properly initialize crypto store via restore_login 2026-05-14 02:25:21 +02:00
requirements.txt feat(encryption): Add E2EE support 2026-05-14 02:10:31 +02:00

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 libolm and python-olm are 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