How do I specify the interface language for CKEditor (jquery version)?

爱⌒轻易说出口 提交于 2019-12-04 17:47:53

问题


My code atm is this simple:

$(document).ready(function(){
   $('textarea').ckeditor();
});

It works flawlessly, I just need to add one more thing: I need to specify the interface language (localisation). I tried reading the CKEditor help site, but it isn't very helpful.

Can anyone tell me where and how do I add any code to specify the language?


回答1:


Try this:

$('textarea').ckeditor({language: 'de'});



回答2:


Untested, but check this out:

http://www.sayopenweb.com/ckeditor-faq/


Q. How do i set language for CKEditor for achieving localization?

A. Use language property for setting the language of CKEditor. By using this property CKEditor menu’s and labels will display the localized language.

CKEditor.replace('divcomponentid', {
        language: 'ja'
})

And if you are using custom config file for creating CKEditor instance use,

CKEditor.editorConfig = function(config) {
    language = "ja";
};

Even one can use javascript variable to set language file to make localization option dynamic.




回答3:


If you are using custom config file for creating CKEditor instance try this.




回答4:


We have a multilingual portal and it is possible to change the language of whole interface. To change the language of the editor I am using ajax, to get the currently selected language. Here is the code which I added in config.js:

CKEDITOR.editorConfig = function(config) {
    var strLanguageName = "en";
    jQuery.ajaxSetup({ async: false, cache: false });
    jQuery.ajax({
        type: "POST",
        url: "/remotemethods/getCurrentLang",
        data: "xml",
        success: setLanguage,
        error: onError
    });
    function setLanguage(data) {
        strLanguageName = jQuery(data).find("lang").text();
    }
    function onError(xhr, ajaxOptions, thrownError) { }
    config.language = strLanguageName;
};



回答5:


Here is one more example (based on CKEditor5):

let theEditor;

ClassicEditor
  .create(document.querySelector('#editor'), {
    // The language code is defined in the https://en.wikipedia.org/wiki/ISO_639-1 standard.
    language: 'sk'
  })
  .then(editor => {
    theEditor = editor;
  })
  .catch(error => {
    console.error(error);
  });
<script src="https://cdn.ckeditor.com/ckeditor5/11.2.0/classic/ckeditor.js"></script>
<script src="https://cdn.ckeditor.com/ckeditor5/11.2.0/classic/translations/sk.js"></script>
<textarea name="content" id="editor">This is some sample content.</textarea>


来源:https://stackoverflow.com/questions/6049020/how-do-i-specify-the-interface-language-for-ckeditor-jquery-version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!