After yii2 starter kit is switched to the Chinese locale, the solution is not displayed normally in the editor
1. When the value of locale is set to english (us), the editor will display normally, but the corresponding language package file /assets/5fbb6f5a/lang/en.js response 404, as shown in Figure 1
2. When the local value is set to Simplified Chinese, when the article is created, the editor is not displayed normally, as shown in Figure 2
3. Refresh the page, check the browser console, and find that the reason is that the corresponding language file /assets/5fbb6f5a/lang/zh.js does not exist, which in turn leads to uncaught typeError: cannot Read propertyHtmlof undefined, as shown in Figure 3
4. Open the URL:http://backend.yii2-starter-kit.terentev.net/content/article/create, it is found that the official example still exists this bug, as shown in Figure 4
5. Check \backend\views\article\_form.php, the editor code is as follows, which is based on asfter/yii2-imperavi-redactor
field($model, 'body')->widget(
\yii\imperavi\Widget::className(),
[
'plugins' => ['fullscreen', 'fontcolor', 'video'],
'options' => [
'minHeight' => 400,
'maxHeight' => 400,
'buttonSource' => true,
'convertDivs' => false,
'removeEmptyTags' => false,
'imageUpload' => Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
7. Open the URL:https://imperavi.com/download/redactor/langs/en/, download en.js, copy to \vendor\asofter\yii2-imperavi-redactor\yii\Imperavi\assets\lang\en.js to solve /assets/5fbb6f5a/lang/en.js Response to 404 problems. Note: If \vendor is not placed in version control, it is recommended to put en.js into version control, and automatically copy to \vendor\asofer\yii2-imperavi-redactor\yii\imperavi\assets\lang\en.js. Refresh the page, /assets/5fbb6f5a/lang/en.js Response 200, as shown in Figure 6
8. Open the URL:https://imperavi.com/download/redactor/langs/zh/, the download failed, and it is decided to manually define the language options of the editor based on the current locale to ensure that the corresponding language package file can be found correctly, and then solve the problem displayed by the editor, edit \backend\views\article\_form.php
language) {
case 'en-US':
$lang = 'en';
break;
case 'ru-RU':
$lang = 'ru';
break;
case 'uk-UA':
$lang = 'uk';
break;
case 'es':
$lang = 'es';
break;
case 'vi':
$lang = 'vi';
break;
case 'zh-CN':
$lang = 'zh_cn';
break;
case 'pl-PL':
$lang = 'pl';
break;
default:
$lang = 'en';
}
?>
field($model, 'body')->widget(
\yii\imperavi\Widget::className(),
[
'plugins' => ['fullscreen', 'fontcolor', 'video'],
'options' => [
'lang' => $lang,
'minHeight' => 400,
'maxHeight' => 400,
'buttonSource' => true,
'convertDivs' => false,
'removeEmptyTags' => false,
'imageUpload' => Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
9. When the local value is set to Simplified Chinese, when the article is created, the editor will display it normally, as shown in Figure 7





