简体   繁体   中英

How to translate Summernote editor

I found that Summernote plugin, has a lot of js files with translations. But how to apply them? I already included them to my page.

Example:

File #1 (js) Save as "summernote-ES.js" :

  (function ($) {
  $.extend($.summernote.lang, {
    'es-ES': {
      font: {
        bold: 'Negrita',

bla, bla, bla (this file has 150 lines) file complete

File #2 (html) index.html:

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.css">
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/monokai.css">
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/mode/xml/xml.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/codemirror/2.36.0/formatting.js"></script>

<!-- include summernote css/js-->
<link href="summernote.css">
<script src="summernote.js"></script>
<script src="[your-url]/summernote-ES.js"></script>

<script>
  $(document).ready(function(){
    $('.summernote').summernote({ lang: 'es-ES' }); 
  })
</script>

You have to include translation source file on your page, a then when you initialize summernote editor, set the language.

<script type="text/javascript">  
    $(".summernote").summernote({
        toolbar: [.....],
        lang: "da-DK"
    });
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.18/summernote-bs4.js"></script>
<script src="~js/lang/summernote-de-DE.js"></script>

$('textarea#des-summernote').summernote({
        placeholder: '',
        tabsize: 2,
        height: 100,
        toolbar: [
            ['style', ['style']],
            ['font', ['bold', 'italic', 'underline']],
            ['para', ['ul', 'ol', 'paragraph', 'clear']],
            ['insert', ['link', 'picture', 'hr']],
        ],
        lang: 'de-DE',
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM