如何指定CKEditor(jquery版本)的界面语言?

发布于 2024-11-08 02:53:25 字数 212 浏览 4 评论 0原文

我的代码 atm 就是这么简单:

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

它工作完美,我只需要添加一件事:我需要指定界面语言(本地化)。我尝试阅读 CKEditor 帮助网站,但它不是很有帮助。

谁能告诉我在哪里以及如何添加代码来指定语言?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

橘虞初梦 2024-11-15 02:53:25

试试这个:

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

Try this:

$('textarea').ckeditor({language: 'de'});
忆梦 2024-11-15 02:53:25

未经测试,但请查看:

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


问。
如何为CKEditor设置语言以实现本地化?

一个。
使用语言属性设置 CKEditor 的语言。通过使用此属性,CKEditor 菜单和标签将显示
本地化语言。

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

如果您使用自定义配置文件来创建 CKEditor 实例使用,

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

甚至可以使用 javascript 变量来设置语言文件以使本地化选项动态化。

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.

软糯酥胸 2024-11-15 02:53:25

如果您使用自定义配置文件来创建 CKEditor 实例,请尝试此操作。

config

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

config

清风无影 2024-11-15 02:53:25

我找到了一种简单的方法来设置 CKE 4 编辑器的语言:

 1. Go to config.js -> 
 2. Then change this line in config.js ->
 3. config.language = "en"

I found an easy way to set up your language to CKE 4 editor :

 1. Go to config.js -> 
 2. Then change this line in config.js ->
 3. config.language = "en"
梦毁影碎の 2024-11-15 02:53:25

我们有一个多语言门户,可以更改整个界面的语言。要更改编辑器的语言,我使用 ajax 来获取当前选择的语言。这是我在 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;
};

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;
};
栀子花开つ 2024-11-15 02:53:25

这是另一个示例(基于 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>

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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文