frontend/widgets/Comment.php
public function registerTranslations()
    {
        if (!isset(Yii::$app->i18n->translations['widgets/comment/*'])) {
            Yii::$app->i18n->translations['widgets/comment/*'] = [
                'class' => 'yii\i18n\PhpMessageSource',
                'sourceLanguage' => 'en-US',
                'basePath' => __DIR__ . '/messages',
                'fileMap' => [
                    'widgets/comment/comment' => 'comment.php',
                ],
            ];
        }
    }
public function registerTranslations()
    {
        if (!isset(Yii::$app->i18n->translations['widgets/comment/*'])) {
            Yii::$app->i18n->translations['widgets/comment/*'] = [
                'class' => 'yii\i18n\PhpMessageSource',
                'sourceLanguage' => 'en-US',
                'basePath' => __DIR__ . '/messages',
                'fileMap' => [
                    'widgets/comment/comment' => 'comment.php',
                ],
            ];
        }
    }
注册翻译