我无法让翻译工作。
[ https://imperavi.com/redactor/版本 3,Yii 2.0.12,PHP 7.1.16]
这是我在 yii2(php 框架)中的代码:
use yii\easyii\widgets\Redactor;
use yii\widgets\ActiveForm;
...
<?= $form->field($model, "content")->widget(Redactor::className(),[
'options' => [
'id'=>"redactor",
'minHeight' => 200,
'imageUpload' => Url::to(['/admin/redactor/upload'], true),
'buttons' => ['html', 'formatting', 'bold', 'italic', 'deleted', 'unorderedlist', 'orderedlist', 'outdent', 'indent', 'alignment', 'horizontalrule', 'link', 'image', 'file','clips'],
'plugins' => ['fontcolor', 'fontfamily', 'fontsize', 'table','clips','filemanager','imagemanager','alignment','fullscreen','video','widget'],
'maxHeight' => 500,
'placeholder' => 'Skriv inn, eller lim inn kopiert tekst og/eller bilder her..',
'toolbarFixed',
'lang' => 'no',
'clickToEdit' => true,
'clickToCancel'=> ['title'=> 'Avbryt'],
],
])->label(false) ?>
这是它生成的内容:
jQuery('#notes-content').redactor({
"imageUpload":"http://byggmannkalk.no/admin/redactor/upload",
"fileUpload":"/admin/redactor/upload","id":"redactor",
"minHeight":200,
"buttons":["html","formatting","bold","italic","deleted","unorderedlist","orderedlist","outdent","indent","alignment","horizontalrule","link","image","file","clips"],
"plugins":["fontcolor","fontfamily","fontsize","table","clips","filemanager","imagemanager","alignment","fullscreen","video","widget"],
"maxHeight":500,
"placeholder":"Skriv inn, eller lim inn kopiert tekst og/eller bilder her..",
"0":"toolbarFixed",
"lang":"nb",
"clickToEdit":true,
"clickToCancel":{"title":"Cancel"},
"imageUploadErrorCallback":function(json){alert(json.error);},
"fileUploadErrorCallback":function(json){alert(json.error);}
});
语言文件给了我一个控制台错误:
VM2426:2 Uncaught TypeError: Cannot read property 'opts' of undefined
at eval (eval at globalEval (jquery.js?v=1523865201:343), <anonymous>:2:13)
at eval (eval at globalEval (jquery.js?v=1523865201:343), <anonymous>:74:3)
at eval (<anonymous>)
at Function.globalEval (jquery.js?v=1523865201:343)
at text script (jquery.js?v=1523865201:9208)
at ajaxConvert (jquery.js?v=1523865201:8243)
at done (jquery.js?v=1523865201:8707)
at XMLHttpRequest.<anonymous> (jquery.js?v=1523865201:9123)
at XMLHttpRequest.send (catcher.js:197)
at Object.send (jquery.js?v=1523865201:9175)
这指向我的语言文件:
(function ($) {
$.Redactor.opts.langs['nb'] = {
html: 'HTML',
....
filename: 'Filnavn (valgfritt)',
edit: 'Endre',
center: 'Midten'
};
})(jQuery);
是否可以修改我创建的编辑器实例,以便将其添加到 $ 而不仅仅是 for $('#notes-content')?
有没有我缺少的参数?
语言文件将在整个程序中使用 Redactor 的许多地方使用,因此我不想修改它们。
非常感谢您的帮助。
附言。我在演示网站(https://imperavi.com/redactor/examples/language/translations/)上注意到他们修改了语言文件:
(function($R)
{
$R.lang['fi'] = {
...
"redo": "Redo"
};
})(Redactor);