sl3dg3
sl3dg3

Reputation: 5190

How to define language-depending content (l18n) in different language-files?

CKEditor 4 stores language-depending content in the lang/-folder. I have written a custom plugin, which I do keep apart from the original CKEditor-folder. Now I would like to keep additional language-depending texts also separated from the original CKEditor-folder. I don't like to simply add the texts with their labels in the original language-files as it was done before.

http://theholyjava.wordpress.com/2011/04/04/how-to-customize-ckeditor-with-your-own-plugins-skins-configurations/ (section "Custom Language") describes how to define own language-files, but I would like CKEditor keep loading the original language-file, and additionally, namely for the plugin, load additional language data.

How could I do this?

Upvotes: 0

Views: 186

Answers (1)

sl3dg3
sl3dg3

Reputation: 5190

Finally figured it out...

  • In the plugin-folder, add a lang-folder: myplugin/lang/
  • Add the language-files (en.js,de.js etc.)
  • In the language-files, write

JS

CKEDITOR.plugins.setLang( 'myplugin', 'en', {
    title: 'My Plugin',
});
  • Under myplugin/plugin.js, register the language-files:

JS

CKEDITOR.plugins.add('myplugin',
{
    lang: 'de,en',
    init: function (editor) {
        // ...
    }
});

Now you can access your locals like this: editor.lang.myplugin.title

The UI Color Plugin gives a good example of that.

Upvotes: 1

Related Questions