←back to thread

Web Translator API

(developer.mozilla.org)
97 points kozika | 1 comments | | HN request time: 0.23s | source
Show context
pwdisswordfishz ◴[] No.44377637[source]
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?

replies(2): >>44377694 #>>44377719 #
1. diggan ◴[] No.44377719[source]
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.