Setting the spellcheck language with lang attribute

As far as I can tell, browsers don’t currently support setting the lang attribute on a contenteditable element to change the language used by the native spellchecker.

Is that correct, or might there be a way to persuade the browser’s spellchecker to use a different language for the editor?

1 Like

Seems that way. Which is weird, as that would be the reasonable way to do this. I’m not aware of another way to choose the spell checker language, but I’ve never really looked into this.

That’s right, it’s not possible. This is largely because browser makers have been developing richtext editing features thinking that it will be the end user who makes all the decisions about what to do where and that they should not be restricted by the site making decisions for them (such as what language to input). We are working on changing their concept of how richtext editors work in practice as of today and this is one such aspect.

Also, we cannot get access to the spell checker in JavaScript for security reasons as users may have added personal data into their own dictionary (name of girlfriend, address, credit card number, etc.) so by checking large amounts of text in JavaScript, one would be able to at some point to determine that certain words that are not in the default dictionary are in the user’s dictionary - which means they must have added them themselves and can be used for finger printing and/or getting to personal details of the user. Not all the browser devs agree with this assessment of a security risk, so it could change at some point.

In this particular case, I’d like to let the user choose a locale and then set the spellchecker to that locale using the lang attribute of the contenteditable element.

You can consider this alternative solution for check spelling and grammar in ProseMirror:

It provides an extensive list of options for configuration. Once of such options allows setting a specific language for proofreading in the editor.

Besides, we also take care about the privacy and security aspects when in comes to processing texts and storing the words added by end users to their personal dictionaries.