更改自定义插件Ckeditor的工具提示语言

时间:2013-07-20 06:07:09

标签: javascript jquery plugins ckeditor fckeditor

我为ckeditor制作了一个自定义插件,现在我正在尝试在所选语言上动态更改工具提示语言。我试图将已翻译的工具提示文本放在ckeditor的lang文件夹中的相应js文件中,但它无效。

1 个答案:

答案 0 :(得分:3)

如果您创建工具栏按钮,请在插件的editor.ui.addButton中添加pluginDefinition.init,如下所示:

CKEDITOR.plugins.add( 'pluginName', {
    lang: 'lan,gua,ges,sup,por,ted,by,this,plu,gin,com,ma,se,pa,ra,ted',
    icons: 'icons,used,by,this,plugin',
    requires: 'anotherPlugin',
    init: function( editor ) {
        // Register the toolbar button.
        if ( editor.ui.addButton ) {
            editor.ui.addButton( 'ButtonName', {
                label: editor.lang.pluginName.labelName, // Your label
                command: 'yourcommand', // Command name
                directional: true, // Depends on BiDi support, optional
                toolbar: 'list,10' // Wherever you want, in fact
            });             
        }
        ...
     }
 });

现在假设您的语言为foo,那么pluginName/lang/foo.js应如下所示:

CKEDITOR.plugins.setLang( 'pluginName', 'foo', {
    labelName: 'My label!'
});

请务必将foo添加到lang对象文字内的pluginDefinition媒体资源中:

CKEDITOR.plugins.add( 'pluginName', {
    lang: 'foo',
    ...
 });

一般来说,editor.lang.pluginName.labelName内部可以使用init,无论您想将它用于何处。

相关问题