Web Translator API

85 kozika 50 6/25/2025, 8:02:51 AM developer.mozilla.org ↗

Comments (50)

vitonsky · 2h ago
As maintainer of https://linguister.io/, should I start work on polyfill for that API?

If this API will be implemented in next few years, there will be browsers who hold up the world in progress.

Linguist have enough many users, so we could expose this API for client side code, and users with browsers where Translation API is not implemented yet, could install Linguist and sites who uses Translation API would works fine. Translation API calls would proxy by Linguist and preferred translator module would be used.

Any thoughts about it?

sandstrom · 5h ago
This would be very useful.

Basically, the 'translate this' button you see on Twitter or Instagram next to comments in foreign languages. This API would make it trivial for all developers to add that to their web apps.

greatgib · 40m ago
Except that it is the user that will pay with his own llm tokens
cAtte_ · 29s ago
how do you know this?
sfmz · 6h ago
https://developer.chrome.com/docs/ai/translator-api

const translator = await Translator.create({ sourceLanguage: 'en', targetLanguage: 'fr', });

await translator.translate('Where is the next bus stop, please?');

ks2048 · 3h ago
So, this is Google Translate built running locally in Chrome? I wonder if it is a small/degraded model or limited languages? Otherwise, how is it not a simple way around the paid Google API?
ameliaquining · 1h ago
The article explains that this feature uses a small (up to 22 GB) language model that runs on-device.

That said, the "simple way around the paid API" problem is something Google has to deal with anyway, because there are a bunch of ways to use Google Translate without paying for it (e.g., the translate.google.com web UI, or the non-JavaScript-exposed "Translate to [language]" feature built into Chrome), and any action that can be taken by a human can in principle also be taken by a script. The only thing to do about it is use secret-sauce server-side abuse detection to block as much of this activity as they can; they can't get all of it but they can get enough to push enough people onto the paid API that the economics pencil out.

jannes · 1h ago
So installing Chrome is going to require 22 GB of disk space now?
ks2048 · 1h ago
It only installs models that explicitly downloaded via this API, it seems.

Also, it says to have 22 GB free, but below (under "Note"...), it says the model takes "around a couple of GB".

cj · 58m ago
Does the API trigger the download automatically, or does it ask for user permission?

(Answered my own question): Doesn't look like it requires the user's permission. Upon first use, the model will start downloading. The user has to wait for the download to finish before the API will work. That could take hours for 22gb.

I presume this can't work on mobile?

https://developer.mozilla.org/en-US/docs/Web/API/Translator_...

ameliaquining · 42m ago
The article indicates that it will only download the model over an unmetered connection, e.g., while the phone is connected to wifi.
sfmz · 2h ago
There's already ways to do translation locally in javascript with neural-nets running in WASM, this is just more convenient.

https://huggingface.co/Xenova/nllb-200-distilled-600M

RockRobotRock · 7h ago
sandstrom · 5h ago
I honestly don't understand the arguments Mozilla have against it.

Safari/webkit is positive (though no official stance yet):

https://github.com/WebKit/standards-positions/issues/339#iss...

yjftsjthsd-h · 4h ago
I don't know enough to understand the DOM argument, but

> The spec assumes a certain form of translation backend, exposing information about model availability, download progress, quotas, and usage prediction. We'd like to minimize the information exposure so that the implementation can be more flexible.

reads to me as Chrome once again trying to export itself verbatim as a "standard" and Mozilla pointing out that that's not really applicable to others.

Also the WebKit post seems to raise somewhat similar arguments but on the basis of fingerprinting/privacy problems.

pwdisswordfishz · 4h ago
Why does it need to be a JavaScript API?

Why not just use the lang= attribute as it was intended, then let the user select text to translate as they wish?

diggan · 4h ago
If it's a HTML attribute, then you can only use it with DOM elements, with no control about when it runs.

Instead, a JS API gives more flexibility and control.

Besides, I think the "lang" attribute is supposed to signal what the language of the text inside that element is, not what it could/should be. So even if going with attributes would be the way forward, a new one would need to be created.

tempodox · 4h ago
It's only implemented in Google Chrome, so go figure.
Uehreka · 3h ago
If Chrome tried to pull this in like 2016, when Google Translate was the only-ish game in town, I’d call them out for it. But we now have multiple competing open weights translation models that are really good, making this kind of service essentially a commodity. One vendor might give users free access to their services to entice them to use their browser, another might differentiate themself by running the model locally and giving the user better privacy guarantees in exchange for performance.

I get that this is one more brick in the wall that teams like LadyBird will have to maintain, but as a web developer I do think more Web API features is generally a good thing, as it makes it easier for smaller shops to implement richer functionality.

seabass · 1h ago
With js being a garbage collected language, what is the benefit of the destroy method here and why is it necessary?
charcircuit · 1h ago
The is no guarantee when it will be garbage collected. For large local models that use a lot of resources they should be unloaded as soon as possible to allow other programs on the computer to use the resources.
minus7 · 2h ago
I was excited that Firefox finally exposed its local translations as API, but it's Chrome-only (still?). Will be nice for userscripts, for example to replace Twitter's translation button that hardly ever works
lynx97 · 7h ago
Can we please NOT autotranslate the web? I have yet to find a site where the quality of autotranslate does not make me stop using that site. I was already irritated when google started to show me de.wikipedia.org articles adespite me explicitly searching for the english article name. Then came Etsy, where the autotranslate quality was so bad I stopped using the site altogether.
diggan · 5h ago
The good news is that if the browsers offered this natively, websites wouldn't need their own implementation of this. And if it's in the client (the browser), you're most likely gonna be able to turn it off globally, just like how you like it.

Worst case scenario a user-script/extension could monkey patch it out, but probably clients will let you disable it.

sandstrom · 5h ago
This is not auto-translation.

Rather, it's an API developers can use to add inline translation to web apps.

For example, under a comment in your app, you can (a) detect the language, and (b) if it's different from the current users/browsers language, offer to translate it with a small link (c) if the user clicks the link, the content is translated to their language.

lofaszvanitt · 4h ago
But Reddit already does it! It's a new form of cultural colonisation by a headless society.
indeyets · 4h ago
So, the browsers have to provide some means for choosing the desired translation engine (add-on API maybe?) and this is a standard API which all of the providers should implement.

right?

troupo · 8h ago
While this might be useful, be mindful:

- it's experimental

- the "specification" is nowhere near a standards track: https://webmachinelearning.github.io/translation-api/

Of course it's already shipped in Chrome, and now Chrome pretends that its own Chrome-only API is somehow standard. Expect people on HN to blame other browsers for not shipping this.

jazzypants · 6h ago
I've been pleasantly surprised by the last few conversations about this type of thing that I've seen. It seems like people are pretty sick of Chrome's IE proclivities.
moron4hire · 5h ago
This is the W3C standardization process.

The W3C is not a prescriptive standardization body. It doesn't have any regulatory power giving it any teeth to go after vendors acting in bad faith. So the W3C process is descriptive and encourages a period of competitive divergence in implementations. It is only after the early adopters have hammered on the features and figured out which parts they like best that a Web API can then start to get standardized.

troupo · 35m ago
> This is the W3C standardization process.

Let me quote the site for you

--- start quote ---

This specification was published by the Web Machine Learning Community Group. It is not a W3C Standard nor is it on the W3C Standards Track.

--- end quote ---

> So the W3C process is descriptive and encourages a period of competitive divergence in implementations.

That is exactly opposite of how the w3c standardization process works

> It is only after the early adopters have hammered on the features and figured out which parts they like best that a Web API can then start to get standardized.

Yes, and until then this work is not supposed to be enabled by default

rhabarba · 8h ago
You had me at "Browser compatibility".
Raed667 · 8h ago
Chrome embeds a small LLM (never stops being a funny thing) in the browser allowing them to do local translations.

I assume every browser will do the same as on-device models start becoming more useful.

Asraelite · 7h ago
What's the easiest way to get this functionality outside of the browser, e.g. as a CLI tool?

Last time I looked I wasn't able to find any easy to run models that supported more than a handful of languages.

JimDabell · 6h ago
That depends on what counts as “a handful of languages” for you.

You can use llm for this fairly easily:

    uv tool install llm

    # Set up your model however you like. For instance:
    llm install llm-ollama
    ollama pull mistral-small3.2

    llm --model mistral-small3.2 --system "Translate to English, no other output" --save english
    alias english="llm --template english"

    english "Bonjour"
    english "Hola"
    english "Γειά σου"
    english "你好"
    cat some_file.txt | english
https://llm.datasette.io
usagisushi · 5h ago
Tip: You might want to use `uv tool install llm --with llm-ollama`.

ref: https://github.com/simonw/llm/issues/575

JimDabell · 5h ago
Thanks!
jan_Sate · 3h ago
That's just the base/stock/instruct model for general use case. There gotta be a finetune specialized in translation, right? Any recommendations for that?

Plus, mistral-small3.2 has too many parameters. Not all devices can run it fast. That probably isn't the exact translation model being used by Chrome.

JimDabell · 2h ago
I haven’t tried it myself, but NLLB-200 has various sizes going down to 600M params:

https://github.com/facebookresearch/fairseq/tree/nllb/

If running locally is too difficult, you can use llm to access hosted models too.

deivid · 2h ago
You can use bergamot ( https://github.com/browsermt/bergamot-translator ) with Mozilla's models ( https://github.com/mozilla/firefox-translations-models ).

Not the easiest, but easy enough (requires building).

I used these two projects to build an on-device translator for Android.

mftrhu · 16m ago
Setting aside general-purpose LLMs, there exist a handful of models geared towards translation between hundred of language pairs: Meta's NLLB-200 [0] and M2M-100 [1] can be run using HuggingFace's transformers (plus numpy and sentencepieces), while Google's MADLAD-400 [2], in GGUF format [3], is also supported by llama.cpp.

You could also look into Argos Translate, or just use the same models as Firefox through kotki [4].

[0] https://huggingface.co/facebook/nllb-200-distilled-600M [1] https://huggingface.co/facebook/m2m100_418M [2] https://huggingface.co/google/madlad400-3b-mt [3] https://huggingface.co/models?other=base_model:quantized:goo... [4] https://github.com/kroketio/kotki

ukuina · 6h ago
ollama run gemma3:1b

https://ollama.com/library/gemma3

> support for over 140 languages

diggan · 5h ago
Try to translate a paragraph with 1b gemma and compare it to DeepL :) Still amazing it can understand anything at all at that scale, but can't really rely on it for much tbh
_1 · 6h ago
If you need to support several languages, you're going to have to have a zoo of models. Small ones just can't handle that many; and they especially aren't good enough for distribution, we only use them for understanding.
rhabarba · 8h ago
While I appreciate the on-device approach for a couple of reasons, it is rather ironic that Mozilla needs to document that for them.
its-summertime · 8h ago
Firefox also has on-device translations for what its worth.
tempodox · 4h ago
What compatibility? It's Chrome-only.
lofaszvanitt · 4h ago
Another useful feature that nobody could've replicated themselves.
nachomg · 8h ago
This gives strong IE vibes.