Crate for translating text?

Does there exit any Rust crate that:

  1. can translate text between languages (say the 10 most commonly used)

  2. is self contained, does not need some external service / api



1 Like

Translate as in for arbitrary text, or for predefined text? If the latter, fluent is what rustc uses (and I believe Firefox as well).

Good clarification question.

Imagine an IRC like chat room. Everyone specifies their "native" language.

Alice / English
Bob / English
Carol / Chinese
Dan / French
Eugene / Spanish

Alice types in the chat room "Hello"

Bob Sees:

Carol sees:
Ni Hao

Dan sees:

Eugene sees:

The way this works is that the server takes Alice's input string, sees Alice's language is English, then for each language option:

  1. run some internal translation model
  2. send Alice's string along w/ translated string

The XY problem is a "multi language chat room"

So you want machine translation? For that you have two options: EIther you use an online service like google translate (allrounder) or deepl (mostly focused on european languages, but also supports chinese, japanese and a couple of other non-european languages) The other option is to have an offline translator like Bergamot (used in the firefox translations addon. Written in C++, but can be compiled to wasm.). The disadvantage of this is that it is less accurate and supports less languages, but it preserves privacy (so no risk of violating the GDPR or CCPA through this) and doesn't require you to pay anyone for translations like you probably need for commercial use of google translate and deepl.

Be aware however that no machine translator captures all nuances of human languages. As such I did recommend to make it very clear when messages are translated to reduce likelihood of mistranslations causing severe issues.



I am okay with solutions that only runs on x86_64. I only need the translation be done server side. I currently do not need in-browser-wasm/webgpu translation.

Agreed. The UI for display msgs is:

user_name: orig msg (that user typed)
translated msg (into reader's lang)

So it's always clear what the user said and what is translated.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.