public function actionRescan() { // ------------------------- RESCAN MESSAGES --------------------------- $result = SourceMessageSearch::getInstance()->extract(); // ----------------------- SHOW RESCAN RESULT -------------------------- $message = Module::t('Rescan successfully completed.') . '<br />'; $message .= Html::ul([Module::t('New messages:') . ' ' . (isset($result['new']) ? $result['new'] : 0), Module::t('Obsolete messages:') . ' ' . (isset($result['obsolete']) ? $result['obsolete'] : 0)]); AppHelper::showSuccessMessage($message); // ---------------------------- REDIRECT ------------------------------- if ($referrer = Yii::$app->getRequest()->referrer) { return $this->redirect($referrer); } else { return $this->redirect(['/translations']); } }
/** * @var View $this */ use uran1980\yii\modules\i18n\Module; use uran1980\yii\modules\i18n\components\grid\GridView; use uran1980\yii\modules\i18n\components\grid\SerialColumn; use uran1980\yii\modules\i18n\components\grid\ActionColumn; use uran1980\yii\modules\i18n\components\grid\DataColumn; use uran1980\yii\modules\i18n\models\search\SourceMessageSearch; use uran1980\yii\modules\i18n\assets\AppTranslateAsset; use uran1980\yii\widgets\scrollToTop\ScrollToTop; use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\web\View; use yii\helpers\Url; $searchModel = SourceMessageSearch::getInstance(); $this->title = Module::t('Translations'); $this->params['breadcrumbs'][] = $this->title; AppTranslateAsset::register($this); ?> <div class="translations-index"> <div class="row"> <div class="col-lg-12"> <span class="pull-left btn-group"> <?php foreach ([SourceMessageSearch::STATUS_ALL => Module::t('All'), SourceMessageSearch::STATUS_TRANSLATED => Module::t('Translated'), SourceMessageSearch::STATUS_NOT_TRANSLATED => Module::t('Not Translated'), SourceMessageSearch::STATUS_DELETED => Module::t('Deleted')] as $status => $name) { ?> <a class="btn btn-default <?php $params = ArrayHelper::merge(Yii::$app->request->getQueryParams(), [$searchModel->formName() => ['status' => $status]]); $route = ArrayHelper::merge(['/translations'], $params);
/** * Extracts messages to be translated from source code. * * Example from yii console: * ``` * php yii message/extract @common/config/messages.php * ``` * * This command will search through source code files and extract * messages that need to be translated in different languages. * * @param string $configFile the path or alias of the configuration file. * You may use the "yii message/config" command to generate * this file and then customize it for your needs. * @throws Exception on failure. */ public function actionExtract($configFile) { SourceMessageSearch::getInstance()->extract(); }