Jump to content

Recommended Posts

Posted

Hi folks

SCAYT (Spell Check As You Type) is a great CKEditor plugin, but does anyone know if it's possible to get it working with multi-language fields? As in configure it to check for English in the English version of a CKE field and German in another for example?

  • Like 2
  • 2 years later...
Posted

So, as I just found this via Google, I'll dig out this thread to help others:

You have to edit site/modules/InputfieldCKEditor/config.js and add the following section inside the CKEDITOR.editorConfig function:

const languages = {
	1010: "de_DE",
	1012: "en_US",
};
const t = setInterval(() => {
	const ed = Object.values(CKEDITOR.instances).filter(x => x.config === config)[0];
	const lang = ed.element.$.parentElement.getAttribute("data-language");
	if (!lang || !languages[lang]) return clearInterval(t);
	if (!ed.scayt) return; // wait until scayt is initialized
	clearInterval(t);
	ed.scayt.setLang(languages[lang]);
}, 100);

You can find out the language IDs by looking at the URL of your language configuration page - it ends with e.g. ?id=1012

Posted

Oh, just noted that to make this work with frontend editing, you'll have to add replace the "const lang" line with the following line:

const lang = ed.element.$.parentElement.getAttribute("data-language") || ed.element.$.parentElement.getAttribute("data-lang");

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...