WICG/proposals

Web Translation API

domenic opened this issue ยท 6 comments

Introduction

Browsers are increasingly offering language translation to their users. Such translation capabilities can also be useful to web developers. This is especially the case when browser's built-in translation abilities cannot help, such as:

  • translating user input or other interactive features;
  • pages with complicated DOMs which trip up browser translation;
  • providing in-page UI to start the translation; or
  • translating content that is not in the DOM, e.g. spoken content.

To perform translation in such cases, web sites currently have to either call out to cloud APIs, or bring their own translation models and run them using technologies like WebAssembly and WebGPU. This proposal introduces a new JavaScript API for exposing a browser's existing language translation abilities to web pages, so that if present, they can serve as a simpler and less resource-intensive alternative.

Read the complete Explainer.

Feedback

Please provide all feedback below.

I welcome feedback in this thread, but encourage you to file bugs against the Explainer.

As someone who usually build multi-lingual applications and websites (mostly in Arabic and English), I think this is going to be very helpful. I can think of

  • Real-time user input translation. We can offer real-time translation of user-generated content such as comments, chat messages, or forum posts.
  • Translate interactive elements, such as tooltips, error messages, or form labels.
  • Translation of user generate content. This is usually a huge pain. Let's say we have a marketplace that can be used in multiple language. We don't ask the user to add their items in all languages available.
  • Simplify localization testing
  • Cost efficiency, by reducing the dependency on external services

I work in e-commerce and can't do justice to portray how impactful this would be. Walmart had to create a whole new website (and organization) to support Spanish. Target still struggles to support Spanish queries. A very large part of (double digits) the e-commerce customer base is a native Spanish speaker (in America). Now extrapolate to other languages/ESL - that's a hell of a lot of people that can't use the services in the same way native English speakers can. The way I see it, enabling standardized translation APIs is no different than enabling alt tags on images. The Web is for everyone.

@domenic This seems to have plenty of support, if you're good with it I can move it over into WICG. (I have admin, just wanted to check with you before moving.)

We work with merchants at Shopify to improve their online store speed. They would often be using some 3rd party translation solutions like: Langify, Weglot, Transcy, and many others.

When it comes to web performance, the main issue is that those services usually include a bunch of client-side JavaScript that detects (through MutationObserver) and translates all of the content. This logic is so expensive, it can be a major blocker from achieving a good Interaction To Next Paint.

I'm not sure if this API aims to cover this. Still, I imagine it would be super impactful to provide a more performant way to translate content on the fly. It can get quite complicated though as just listening for the text nodes is not enough. The API would also have to work with attributes (different links, images, backgrounds, etc.). At least that's what those 3rd tools are able to do currently.

@cwilso thank you, yes, let's move it!

Done, and you (@domenic) have admin there: https://github.com/WICG/translation-api.