Skip to content

[Feature Request] Automatic message translation #104

Open

Description

@th2tran

Dev Team,

What do you think of this plan to implement automatic message translation to the user's preferred language.

automatic-translation-plan.md

I can help out with the implementation.

Let's use this space to sort out the UX and low-level technical details.

PLAN

On-device automatic chat translation

Goal

Automatically show incoming chat messages in the user's preferred language without
sending message text to a translation service. Preserve the original messages and
make them available through "Show original".

Bundle English-to-French and French-to-English translation with the Vector
installer. Provide other languages as optional, plug-and-play data downloads.

Model selection

Use Bergamot tiny INT8 translation models as the initial size-first choice.
These translation-specific models avoid shipping a large multilingual LLM or
NLLB model covering languages the user does not need.

Payload baseline

Mozilla's published Bergamot registry provides these reference sizes:

Resources Installed size Estimated compressed size
English to French 25.9 MB 16.9 MB
French to English 26.8 MB 17.8 MB
Both directions, sharing their identical vocabulary 51.8 MB 34.3 MB

These figures include model weights, tokenizers and translation shortlists.
Approximately 17 MB is the size of one direction's weights alone, not its complete
language pack.

Initial budget: approximately 35 MB of compressed model data, plus the inference
runtime.
These are reference artifact sizes, not measured increases in Vector's
installers. Compression differs between installer formats.

The reference registry belongs to the retired Firefox Translations extension.
Pin and validate specific model artifacts; do not depend on that extension or
assume these are the latest available models.

Runtime

Start by evaluating Bergamot compiled to WebAssembly, CPU-only, in a dedicated
worker
:

  • One runtime artifact across desktop, Android and Vector Web.
  • No Python, CUDA, ONNX Runtime or GPU dependencies.
  • No inference on the UI thread.
  • Identical language-pack files across platforms.

Use standard Wasm SIMD where supported, not Firefox-specific acceleration.
Avoid requiring threads or SharedArrayBuffer.

This is a candidate, not an assumption that Wasm is necessarily the smallest
deployment. Build a stripped runtime and measure its packaged size, cold-start
time, memory consumption and translation latency before committing. Evaluate
native integration if those measurements justify it.

Validate WKWebView, WebKitGTK, WebView2 and Android WebView. Review any necessary
worker and WebAssembly CSP permissions narrowly.

Vector's existing Whisper web integration provides worker and
model-management precedent. Whisper itself does not translate arbitrary chat text.

Installer resources

Include:

  • Translation runtime.
  • English-to-French and French-to-English models.
  • A shared tokenizer where the selected files are byte-identical.
  • A pinned manifest, checksums and license notices.

Add resources through Tauri's bundle configuration
and verify Android packaging separately. Ship weights once as resources rather
than also embedding them in the executable. Avoid retaining both compressed and
extracted copies unnecessarily.

English/French translation must work offline immediately after installation.

Optional language packs

Expose Settings > Translation > Languages with:

  • Supported languages and translation directions.
  • Download and installed sizes.
  • Download progress and cancellation.
  • Installation and removal.
  • Local-file import for offline installation.

Each pack contains data only:

  • Quantized model weights.
  • Tokenizer and translation shortlist.
  • A manifest identifying source and target languages, pack version and runtime
    compatibility.
  • License and provenance information.

Use authenticated manifests and verified file hashes. Enforce bounded extraction,
reject unsafe archive paths and install atomically. Interrupted or invalid
downloads must not replace a working pack.

Downloads must use Vector's existing transport policy. Packs must not contain
downloadable executable plugins. Installing a compatible pack must not require
an application restart.

Language routing

Use English as the initial pivot language:

German -> English -> French

This avoids distributing models for every possible language pair. Pivoting
requires two inference passes and can reduce translation quality.

Advertise only routes for which compatible models actually exist. Show required
packs explicitly rather than silently downloading them. Additional language
availability is limited by the selected model family's coverage.

Chat behavior

  • Automatic translation is opt-in.
  • Initialize the target language from the device locale, with an explicit override.
  • Allow per-chat overrides and "never translate this language".
  • Prioritize visible incoming messages rather than translating entire histories.
  • Show "Translated from French" and a "Show original" action.
  • Preserve the original message and protocol payload unchanged.
  • Leave the original visible when language detection is uncertain.
  • Keep manual translation available for ambiguous or short messages.
  • Report unsupported languages, missing packs and inference failures explicitly.
  • Never fall back to a cloud translation service.

Protect links, mentions, code and formatting structurally. Validate that protected
content survives translation rather than assuming the model will faithfully
reproduce placeholder tokens.

Outgoing composition translation and translated notifications are outside the
initial scope.

Architecture, state and privacy

Keep translation policy and scheduling in vector-core, with inference behind a
platform interface.

Do not add translation payloads to
CompactMessage. Keep translated text separate
from the original message representation.

Start with an account-scoped memory cache keyed by:

  • Message identity, including its conversation context where needed.
  • Message content revision.
  • Target language.
  • Model version or versions used by the translation route.

Required behavior:

  • Invalidate entries on message edits or deletion.
  • Discard stale results after account changes.
  • Cancel queued work when leaving a conversation.
  • Unload idle models.
  • Share immutable model files across accounts, never message text or results.
  • Apply Vector's session binding and UI emission rules to asynchronous work.

Defer persistent translation caching because it introduces additional
plaintext-retention obligations.

Implementation sequence

1. Size and quality spike

  • Pin English/French artifacts and verify redistribution terms.
  • Build the smallest practical runtime from pinned source inputs.
  • Measure actual packaged size, installer overhead and installed disk usage.
  • Measure cold start, peak memory and short-message latency on target platforms.
  • Evaluate representative English/French chat, including slang, accents,
    punctuation, short replies, mixed-language text and protected content.
  • Agree on concrete size, latency, memory and quality acceptance thresholds before
    advancing.

Go/no-go gate: acceptable chat quality and measured deployment overhead, not
model-weight size alone.

2. Offline foundation

  • Package bundled English/French resources.
  • Implement worker lifecycle and inference integration.
  • Add language detection and supported-route resolution.
  • Add bounded scheduling, cancellation and account-scoped memory caching.
  • Add focused correctness tests.

3. Chat integration

  • Add translation settings and per-chat controls.
  • Translate visible incoming messages automatically when enabled.
  • Provide translation status and access to originals.
  • Handle edits, deletion, navigation and account changes.
  • Verify protected text and formatting preservation.

4. Pack management

  • Add the language catalog and authenticated manifests.
  • Implement downloads through Vector's transport layer.
  • Implement verification, atomic installation, removal and offline import.
  • Test incompatible packs, corrupted files, interruption and failed installation.

5. Platform and release validation

  • Validate desktop, Android and Vector Web.
  • Verify bundled English/French operation with networking disabled.
  • Verify model downloads honor the configured transport and never fall back to
    direct connections.
  • Verify the source-only F-Droid build, including a
    reproducible source-build path for any shipped Wasm runtime.
  • Run the repository's required frontend checks and relevant build/test commands
    when implementation changes land.

Sources

Runtime licensing and each selected model's redistribution terms must be checked
separately before bundling.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions