如何翻译 Summernote 编辑器
How to translate Summernote editor
我发现Summernote插件,有很多带有翻译的js文件。但是如何应用它们呢?我已经将它们包含在我的页面中。
您必须在页面上包含翻译源 file,然后在初始化 summernote 编辑器后,设置语言。
<script type="text/javascript">
$(".summernote").summernote({
toolbar: [.....],
lang: "da-DK"
});
</script>
编辑:
如果您愿意,也可以使用 CDN
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/lang/summernote-da-DK.js"></script>
示例:
文件 #1 (js) 另存为 "summernote-ES.js" :
(function ($) {
$.extend($.summernote.lang, {
'es-ES': {
font: {
bold: 'Negrita',
bla, bla, bla(这个文件有 150 行)
file complete
文件 #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>
<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',
});
我发现Summernote插件,有很多带有翻译的js文件。但是如何应用它们呢?我已经将它们包含在我的页面中。
您必须在页面上包含翻译源 file,然后在初始化 summernote 编辑器后,设置语言。
<script type="text/javascript">
$(".summernote").summernote({
toolbar: [.....],
lang: "da-DK"
});
</script>
编辑:
如果您愿意,也可以使用 CDN
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/lang/summernote-da-DK.js"></script>
示例:
文件 #1 (js) 另存为 "summernote-ES.js" :
(function ($) {
$.extend($.summernote.lang, {
'es-ES': {
font: {
bold: 'Negrita',
bla, bla, bla(这个文件有 150 行) file complete
文件 #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>
<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',
});