WICG / proposals

A home for well-formed proposed incubations for the web platform. All proposals welcome.
https://wicg.io/
Other
233 stars 16 forks source link

Web Translation API #147

Closed domenic closed 6 months ago

domenic commented 7 months ago

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:

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.

ahmadalfy commented 7 months ago

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

parkjoon commented 6 months ago

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.

cwilso commented 6 months ago

@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.)

krzksz commented 6 months ago

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.

domenic commented 6 months ago

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

cwilso commented 6 months ago

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