{"id":282803,"date":"2016-12-21T10:10:03","date_gmt":"2016-12-21T07:10:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282803"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282803","title":{"rendered":"Yii2-advanced: \u0414\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0432 Redis"},"content":{"rendered":"<p>\u0412 Yii2 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>  <b>1.<\/b> \u0424\u0430\u0439\u043b \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, \u0432\u0438\u0434\u0430: \u043a\u043b\u044e\u0447=&gt;\u043f\u0435\u0440\u0435\u0432\u043e\u0434 (\u0433\u0438\u0431\u043a\u043e);<br \/>  <b>2.<\/b> \u0424\u0430\u0439\u043b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c .po,.mo \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 (\u043d\u0443\u0436\u0435\u043d \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0431\u044b\u0441\u0442\u0440\u043e);<br \/>  <b>3.<\/b> \u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 mysql, \u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c (\u043b\u0443\u0447\u0448\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u0438\u043b\u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0442\u0430\u043a \u043a\u0430\u043a yii \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043f\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 );<\/p>\n<p>  \u0418\u043b\u0438 \u0441\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u0437\u044f\u0432 \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u0432 \u0431\u0430\u0437\u0435 \u043d\u043e \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c (\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u0438 \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f).<\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435<\/h3>\n<p>  \u0412\u044b\u0437\u043e\u0432 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c Yii::t(). \u0425\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044b \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u043c \u0432 MySQL. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u044f\u0437\u044b\u043a\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432 Redis. \u0421\u0431\u043e\u0440 \u043a\u043b\u044e\u0447\u0435\u0439 (\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439) \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0438\u043c.<\/p>\n<h4>\u0412 \u0447\u0435\u043c \u043f\u043b\u044e\u0441\u044b:<\/h4>\n<p>  <\/p>\n<ul>\n<li> \u0431\u044b\u0441\u0442\u0440\u0435\u0435;<\/li>\n<li> \u0433\u0438\u0431\u0447\u0435;<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 i18n.php<\/h3>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0439 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code>php yii message\/config @common\/config\/i18n.php<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0444\u0430\u0439\u043b i18n.php \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 common\/config\/ \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">common\/config\/i18n.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\"> return [     'color' =&gt; null,     'interactive' =&gt; true,     'help' =&gt; null, \t'sourcePath' =&gt;  __DIR__. '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR,     'languages' =&gt; ['ru-RU','uk-UA','en-US'],\/\/\u044f\u0437\u044b\u043a\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c     'translator' =&gt; 'Yii::t',     'sort' =&gt; false,     'overwrite' =&gt; true,     'removeUnused' =&gt; false,     'markUnused' =&gt; true,     'except' =&gt; [         '.svn',         '.git',         '.gitignore',         '.gitkeep',         '.hgignore',         '.hgkeep',         '\/messages',         '\/BaseYii.php',     ],     'only' =&gt; [         '*.php',     ],     'format' =&gt; 'db',     'db' =&gt; 'db',     \/\/'messageTable' =&gt; '{{%message}}', \/\/ \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u043a \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u044f  \u0442\u0430\u0431\u043b\u0438\u0446\u0430 gr_dictionary     'sourceMessageTable' =&gt; '{{%gr_dictionary}}',\/\/ \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432     'ignoreCategories' =&gt; ['yii'], ]; <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 MySQL<\/h3>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0440\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0441 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430\u043c\u0438:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">gr_language (\u044f\u0437\u044b\u043a\u0438)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">CREATE TABLE IF NOT EXISTS `gr_language` (   `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,   `code_lang` varchar(255) NOT NULL,   `local` varchar(255) NOT NULL,   `name` varchar(255) NOT NULL,    `status` tinyint(4) NOT NULL DEFAULT '1',   UNIQUE KEY `code_lang` (`code_lang`),   UNIQUE KEY `local` (`local`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;   INSERT INTO `gr_language` (`id`, `code_lang`, `local`, `name`, `status`)  VALUES (1, 'en', 'en-US', 'English',  1), (2, 'ru', 'ru-RU', '\u0420\u0443\u0441\u0441\u043a\u0438\u0439',  1), (3, 'uk', 'uk-UA', '\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430', 1); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">gr_dictionary_keys (\u043a\u043b\u044e\u0447\u0438)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\"> -- \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c CREATE TABLE IF NOT EXISTS `gr_dictionary_keys` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,   `key` varchar(250) NOT NULL,   UNIQUE KEY `id` (`id`),   KEY `key` (`key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">gr_dictionary (\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044b)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">-- \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430\u043c\u0438 CREATE TABLE IF NOT EXISTS `gr_dictionary` (   `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,   `language_id` smallint(5) unsigned NOT NULL,   `key`  int(10) unsigned NOT NULL,   `value` varchar(255) NOT NULL COMMENT '\u0448\u0430\u0431\u043b\u043e\u043d',   `translator` text NOT NULL  COMMENT '\u043f\u0435\u0440\u0435\u0432\u043e\u0434',   `type` set('w','m') DEFAULT NULL COMMENT 'w\/m \u0441\u043b\u043e\u0432\u043e\/\u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435',   `status` tinyint(4) NOT NULL DEFAULT '1', \tCONSTRAINT `gr_dictionary_ibfk_1`  \t  FOREIGN KEY (`language_id`)  \t  REFERENCES `gr_language` (`id`)  \t  ON DELETE CASCADE  \t  ON UPDATE CASCADE, \tCONSTRAINT `gr_dictionary_ibfk_2`  \t  FOREIGN KEY (`key`)  \t  REFERENCES `gr_dictionary_keys` (`id`)  \t  ON DELETE CASCADE  \t  ON UPDATE CASCADE,  UNIQUE KEY `language_id` (`language_id`,`key`,`type`),  KEY `code_lang` (`language_id`),  KEY `type` (`type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0434\u043e \u0441\u0431\u043e\u0440\u0430 \u043a\u043b\u044e\u0447\u0435\u0439, \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \\yii\\console\\controllers\\MessageController \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u043a\u043b\u044e\u0447\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043c \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u043d\u0435\u0433\u043e. <\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b console\\controllers\\Message2Controller.php \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">console\\controllers\\Message2Controller.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">namespace console\\controllers; use Yii; use yii\\console\\Exception;  class Message2Controller extends \\yii\\console\\controllers\\MessageController {     \/**      * Saves messages to database      *      * @param array $messages  \u042d\u0442\u043e \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043b\u044e\u0447\u0435\u0439 [[\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438]=&gt;[[\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435],[...]] ,... ]      * @param \\yii\\db\\Connection $db      * @param string $sourceMessageTable \u041d\u0430\u0448\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432      * @param string $messageTable  \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c      * @param boolean $removeUnused      * @param array $languages  \u042d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u044f\u0437\u044b\u043a\u043e\u0432 languages \u0438\u0437 i18n.php ['ru-RU',...]      * @param boolean $markUnused      *\/      protected function saveMessagesToDb($messages, $db, $sourceMessageTable, $messageTable, $removeUnused, $languages, $markUnused)     {         try{             $pr_iskey=Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT `id`  FROM `gr_dictionary_keys` WHERE `key`=:key&quot;);             $pr_inskey=Yii::$app-&gt;db-&gt;createCommand(&quot;INSERT INTO `gr_dictionary_keys`( `key`) VALUES (:key)&quot;);             $pr_delkey=Yii::$app-&gt;db-&gt;createCommand(&quot;DELETE FROM `gr_dictionary_keys` WHERE `id`=:id&quot;);              $id_lang=[];             $pr_l=Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT SQL_NO_CACHE id FROM gr_language WHERE local=:local LIMIT 1&quot;);             foreach ($languages as $language) {                 if(!isset($id_lang[$language])){                     $id_language=(int)$pr_l-&gt;bindValue(&quot;:local&quot;, $language,2)-&gt;queryScalar();                     if(empty($id_language)){                         continue;                       \/\/  throw new Exception(&quot;Unknow lang type $language&quot;);                     }                     $id_lang[$language]=(int)$id_language;                 }              }              if(empty($id_lang))throw new Exception(&quot;empty lang&quot;);             \/\/ALTER TABLE `yii2advanced`.`gr_dictionary` ADD UNIQUE (`language_id`, `key`, `type`);             $pr_d=Yii::$app-&gt;db-&gt;createCommand(&quot;INSERT IGNORE INTO `gr_dictionary`( `language_id`, `key`, `value`, `type`) VALUES (:language_id,:key,:value,:type)&quot;);             foreach ($messages as  $category =&gt; $msgs){                 list($type,$key)=explode(&quot;:&quot;, $category);                  if(empty($id=$pr_iskey-&gt;bindValue(&quot;:key&quot;, $key,2)-&gt;queryScalar())){                     $pr_inskey-&gt;bindValue(&quot;:key&quot;, $key,2)-&gt;execute();                     $id=Yii::$app-&gt;db-&gt;lastInsertID;                 }                  foreach ($id_lang as $id_language) {                     $pr_d-&gt;bindValue(&quot;:language_id&quot;, $id_language,1)-&gt;bindValue(&quot;:key&quot;, $id,1)-&gt;bindValue(&quot;:value&quot;, $msgs[0],2)-&gt;bindValue(&quot;:type&quot;, $type,2)-&gt;execute();                 }             }               \/\/ \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0438 \u0441\u043e status=1 (\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445)             $query=Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT SQL_NO_CACHE dk.`id`,CONCAT(d.`type`,':',dk.`key`) as 'key_' FROM `gr_dictionary` d,gr_dictionary_keys dk WHERE d.`key`=dk.id AND  status=1&quot;)-&gt;query();             \/\/$pr_del=Yii::$app-&gt;db-&gt;createCommand(&quot;DELETE FROM `gr_dictionary` WHERE `key`=:key&quot;);             while(($data=$query-&gt;read())!=false){                 if(array_key_exists($data['key_'], $messages)===false){                     \/\/$pr_del-&gt;bindValue(&quot;:key&quot;, $data['id'],1)-&gt;execute();                     $pr_delkey-&gt;bindValue(&quot;:id&quot;, $data['id'],1)-&gt;execute();                 }             }              Yii::$app-&gt;db-&gt;createCommand(&quot;ALTER TABLE gr_dictionary AUTO_INCREMENT = 1;&quot;)-&gt;execute();         }catch (\\Exception $e){            \/\/\u043f\u0438\u0448\u0435\u043c \u0432 \u043b\u043e\u0433         }     } } <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<p>  \u0421\u0443\u0442\u044c \u0442\u0443\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 saveMessagesToDb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 gr_dictionary \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 common\/config\/i18n.php <\/p>\n<pre><code class=\"php\">'sourceMessageTable' =&gt; '{{%gr_dictionary}}'<\/code><\/pre>\n<p>  \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/yiisoft\/yii2\/blob\/master\/docs\/guide-ru\/tutorial-i18n.md#\u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438-\u0441-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u043c-\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c\">Yii::t() <\/a>.\u041d\u043e \u043c\u043e\u0436\u043d\u043e \u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0442\u0443\u0442 \u043c\u044b \u0443\u0436\u0435 \u0440\u0435\u0448\u0430\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u043c \u043b\u0443\u0447\u0448\u0435. \u0414\u043e\u0431\u0430\u0432\u0438\u043b \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0439, \u0430 \u0441 \u043d\u0438\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0435\u0441\u043b\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0441\u0431\u043e\u0440 \u043a\u043b\u044e\u0447\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0443: <\/p>\n<pre><code class=\"php\">php yii message2\/extract @common\/config\/i18n.php<\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (gr_dictionary \u0438 gr_dictionary_keys). \u041f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044f\u0437\u044b\u043a\u0443 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b gr_language \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430.<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c components i18n <\/h3>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 components \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 common\\config\\main.php:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">common\\config\\main.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\"> ...  'language'=&gt; 'ru-RU',  'sourceLanguage' =&gt; 'en-US',  'components' =&gt; [ \t 'i18n' =&gt; [ \t\t\t\t'translations' =&gt; [ \t\t\t\t\t'*' =&gt; [ \t\t\t\t\t\t'class' =&gt; 'common\\models\\AltDbMessageSource',\/\/ \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441  yii\\i18n\\DbMessageSource \t\t\t\t\t], \t\t\t\t], \t\t\t], \t'lng' =&gt; [ \t\t'class' =&gt; '\\common\\components\\LanguageExtension', \t], \t... <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<ol>\n<li> \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Yii i18n \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 Yii::$app-&gt;t().\u041a\u043b\u0430\u0441\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u044d\u0442\u043e yii\\i18n\\DbMessageSource \u043d\u043e \u043c\u044b \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c common\\models\\AltDbMessageSource.\n<\/li>\n<li>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 lng \u044d\u0442\u043e \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \\common\\components\\LanguageExtension \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 Redis <\/li>\n<\/ol>\n<p>  <\/p>\n<h3>\u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c yii\\i18n\\DbMessageSource<\/h3>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">yii\\i18n\\DbMessageSource<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">namespace common\\models; use Yii;   class  AltDbMessageSource extends  \\yii\\i18n\\MessageSource {      public $sourceLanguage;      public function init()     {         parent::init();         if ($this-&gt;sourceLanguage === null) {             $this-&gt;sourceLanguage = Yii::$app-&gt;sourceLanguage;         }     } \t     protected function translateMessage($category, $message, $language)     {         return  Yii::$app-&gt;lng-&gt;translate($category);     }      public function translate($category, $message, $language)     {         if ( $language !== $this-&gt;sourceLanguage ) {             return $this-&gt;translateMessage($category, $message, $language);         } else {             return false;         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041c\u0435\u0442\u043e\u0434 translateMessage \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c Yii::t(&#8216;\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f&#8217;,&#8217;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435&#8217;). \u0422\u0443\u0442 \u0432\u0430\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0438\u0434 \u043a\u043b\u044e\u0447\u0430. \u041c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u043f\u0430\u0440\u0430\u0442\u043e\u0440 <code>:<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 Redis \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043f\u0430\u043f\u043a\u0438 \u0441 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0435\u0439, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u044c. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443: \u0442\u0430\u043a\u0438\u0435 \u043a\u043b\u044e\u0447\u0438 <code>Yii::t('ru-RU:type:uniq_wiev','\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435')<\/code> \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432 RedisAdmin \u0442\u0430\u043a:<\/p>\n<ul>\n<li> ru-RU:<br \/> \n<ul>\n<li>type:<br \/> \n<ul>\n<li> uniq_wiev: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <\/li>\n<li> uniq_wiev: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <\/li>\n<li> uniq_wiev: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  \u0427\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Redis \u0442\u0430\u043a\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438:<\/p>\n<pre><code class=\"php\">$redis-&gt;executeCommand(&quot;KEYS&quot;,[&quot;KEY&quot; =&gt; $lang_key.&quot;:&quot;.$type.&quot;:*&quot;]); $redis-&gt;executeCommand(&quot;KEYS&quot;,[&quot;KEY&quot; =&gt; $lang_key.&quot;:*&quot;]);<\/code><\/pre>\n<p>  \u041a\u043b\u044e\u0447 \u044f\u0437\u044b\u043a\u0430 ru-RU \u0438 \u0434\u0440. \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f Redis \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \\common\\components\\LanguageExtension.<\/p>\n<h3>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \\common\\components\\LanguageExtension<\/h3>\n<p>  \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u0438\u0437 Redis \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0435\u0441\u043b\u0438 Redis \u043e\u0442\u0432\u0430\u043b\u0438\u043b\u0441\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 beforeAction \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">beforeAction<\/b><\/p>\n<div class=\"spoiler_text\"> public function beforeAction($action)<br \/>  {<br \/>   Yii::$app-&gt;lng-&gt;initModel();\/\/\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 redis \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043b\u043e\u0432 \u0438\u0437 \u0431\u0430\u0437\u044b Mysql gr_dictionary<br \/>  \u2026<br \/>  }  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">common\\components\\LanguageExtension<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">namespace common\\components\\extensions;  use  Yii; use common\\components\\exceptions\\LanguageException; use yii\\db\\Exception; use PDO;   \/**  * Class LanguageExtension  * @package common\\components\\extensions  * \u0417\u0430\u0434\u0430\u0447\u0438:  * \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044f  * \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f redis  *\/ class LanguageExtension extends \\yii\\base\\Object {     private $language;                      \/\/ \u043a\u043e\u0434 \u044f\u0437\u044b\u043a\u0430 - \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e ru     private $w = [];                        \/\/ \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043b\u043e\u0432     private $m = [];                        \/\/ \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439     private $storageConnection;             \/\/ \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u0434\u0438\u0441\u0443     private $storageStatus;                 \/\/ \u0441\u0442\u0430\u0442\u0443\u0441 \u0440\u0435\u0434\u0438\u0441\u0430 \u0434\u043b\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044f     private $numbDb;                     \/\/ \u0431\u0430\u0437\u0430 redis     private $default_key;                   \/\/ \u0444\u043b\u0430\u0433 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f     private $expire;      public function __construct() {         try{             $this-&gt;expire = Yii::$app-&gt;params['secretKeyExpire']??(60 * 60 * 60);             $this-&gt;language =  \\Yii::$app-&gt;language;             $language=LanguageExtension::currentLang();              if(!empty($language)){                 if($this-&gt;idKeyLang($language)) {                     $this-&gt;language= $language;                 }             }             $this-&gt;numbDb=Yii::$app-&gt;params['redisLangDB']??11;              $this-&gt;storageStatus = false;             $this-&gt;default_key=  $this-&gt;language.&quot;:index&quot;;             $this-&gt;storageConnection = new \\yii\\redis\\Connection([                 'hostname' =&gt; Yii::$app-&gt;params['redisHost'],               \/\/  'password' =&gt; '',                 'port' =&gt; 6379,                 'database' =&gt; $this-&gt;numbDb,             ]);              if(empty($this-&gt;language)) throw new LanguageException(&quot;not default language&quot;,0);             $this-&gt;init();         }catch ( LanguageException $event){            \/\/ echo $event-&gt;getMessage();          }catch ( \\yii\\db\\Exception $event){              $this-&gt;init();         }catch (\\Exception $event){            \/\/ echo  $event-&gt;getMessage();         }      }      public function __destruct() {         try{             if($this-&gt;storageConnection-&gt;isActive)  $this-&gt;storageConnection-&gt;close();         }catch (\\Exception $event){         }     }      public function initModel()     {         return new LanguageExtension();     }      \/**      * \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0430. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044f. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0432 \u0440\u0435\u0434\u0438\u0441\u0435. \u041f\u043e\u043b\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0432 \u0440\u0435\u0434\u0438\u0441.      *\/     public function init(){         try{             $this-&gt;storageConnection-&gt;open();             \/\/if($this-&gt;storageConnection-&gt;getIsActive()==false) throw new LanguageException(&quot;No connect Redis &quot;,0);              \/\/ \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u043b\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0432 redis             if(!$this-&gt;isFullData()){                 \/\/ \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438\u0437 mysql \u0431\u0430\u0437\u044b \u0441\u043b\u043e\u0432 \u0432 redis                 $this-&gt;loadRedis();             }             $this-&gt;storageStatus = true;         } catch ( \\yii\\db\\Exception $event) {             $this-&gt;storageStatus = false;             \/\/ \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0430. \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 $w  \u0438 $m  \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u044f\u0437\u044b\u043a\u0443 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443.             $this-&gt;loadVariable();         }     }      public static function currentLang(){         try{             $language = isset($_COOKIE['userLang']) ? $_COOKIE['userLang'] : null;             if(!$language && Yii::$app-&gt;session-&gt;has('userLang')) {$language = Yii::$app-&gt;session('userLang');}             if(empty($language))$language=\\Yii::$app-&gt;language;             return $language;         }         catch (\\Exception $e){             \/\/print_r($e-&gt;getMessage());exit;         }     }      private function idKeyLang(string $key){         if(!empty($key)){             return Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT `id`  FROM `gr_language` WHERE local=:local&quot;)-&gt;bindValue(&quot;:local&quot;, $key,PDO::PARAM_STR)-&gt;queryScalar();         }         return false;     }      \/**      * @param string $type      * @param string $key      * @return string      * \u0421\u0442\u0440\u043e\u0438\u0442 \u043a\u043b\u044e\u0447      *\/     private function getKeyMD5(string $type,string $key):string {         return $this-&gt;language.&quot;:&quot;.$type.&quot;:&quot;.md5($key);     }      \/**      * @return bool      * \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u043c      *\/     private function loadVariable():bool{         try{               \/\/ \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0430. \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 $w  \u0438 $m  \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u044f\u0437\u044b\u043a\u0443 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443.             \/\/$language_id=Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT `id`  FROM `gr_language` WHERE local=:local&quot;)-&gt;bindValue(&quot;:local&quot;, $this-&gt;language,PDO::PARAM_STR)-&gt;queryScalar();             $language_id=$this-&gt;idKeyLang($this-&gt;language);              $res=\\Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT  d.`type`,d.`value`,d.`translator`, dk.`key`  FROM `gr_dictionary` d,gr_dictionary_keys dk WHERE d.`key`=dk.id AND d.language_id=:language_id&quot;)                 -&gt;bindValue(&quot;:language_id&quot;, $language_id,PDO::PARAM_INT)-&gt;query();             $this-&gt;w=$this-&gt;m=[];             while(($data=$res-&gt;read())!=false){                 if(method_exists($this, $data['type'])){                     $this-&gt;{$data['type']}[$this-&gt;getKeyMD5($data['type'],$data['key'])]=$data['translator'];                 }             }              return true;         }catch (\\Exception $event){             echo $event-&gt;getLine().&quot;|&quot;.$event-&gt;getMessage();exit;             return false;         }     }      \/**      * @return bool      * \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043b\u043e\u0432 \u0432 redis \u0438\u0437 mysql (\u044f\u0437\u044b\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b)      *\/     private function loadRedis():bool{         try{              $language_id=$this-&gt;idKeyLang($this-&gt;language);             \/\/$res=\\Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT `type`,`key`, `value`,`translator`  FROM `gr_dictionary` WHERE language_id=:language_id&quot;)             \/\/-&gt;bindValue(&quot;:language_id&quot;, $language_id,PDO::PARAM_INT)-&gt;queryAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP ,1);             $res=\\Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT d.`type`,dk.`key`, d.`value`,d.`translator`  FROM `gr_dictionary` d,gr_dictionary_keys dk WHERE d.`key`=dk.id AND d.language_id=:language_id&quot;)                 -&gt;bindValue(&quot;:language_id&quot;, $language_id,PDO::PARAM_INT)-&gt;query();              $this-&gt;storageConnection-&gt;executeCommand('SETEX', [ &quot;KEY&quot; =&gt;  $this-&gt;default_key,&quot;SECONDS&quot;=&gt;$this-&gt;expire,&quot;VALUE&quot;=&gt; &quot;1&quot;]);              while(($data=$res-&gt;read())!=false){                 $this-&gt;storageConnection-&gt;executeCommand('SETEX', [&quot;KEY&quot; =&gt; $this-&gt;getKeyMD5($data['type'],$data['key']),&quot;SECONDS&quot;=&gt;$this-&gt;expire,&quot;VALUE&quot;=&gt; $data['translator']]);             }              if(empty($this-&gt;storageConnection-&gt;executeCommand('LASTSAVE', [] )))             $this-&gt;storageConnection-&gt;executeCommand('BGSAVE', [] );              return true;          }catch (\\Exception $event){             echo $event-&gt;getMessage();exit;             return false;         }     }      \/**      * \u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c Redis      *\/     public function flushdb(){         try{             if($this-&gt;storageConnection-&gt;isActive) $this-&gt;storageConnection-&gt;executeCommand('FLUSHDB');             else {                 $this-&gt;w=[];                 $this-&gt;m=[];             }         }catch (\\Exception $event){          }     }       \/**      * @return bool      * \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0432 redis \u0441\u043b\u043e\u0432 \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u044e\u0447\u0435\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044f      *\/     private function isFullData():bool     {         try{             $res= $this-&gt;storageConnection-&gt;executeCommand('INFO', [ ] );             preg_match(&quot;\/.*db$this-&gt;numbDb:keys=([\\d])*.*?\/uis&quot;,$res,$arr);             if(isset($arr[1]) && $arr[1]&gt;1){                 return  $this-&gt;exists($this-&gt;default_key);             }             return false;         }catch (\\Exception $event){             echo $event-&gt;getMessage();             return false;         }      }       \/**      * @param string $key      * @return string      * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u043e \u043f\u043e \u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0443 \u0438\u0437 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f      *\/     public function w(string $key) : string {         return $this-&gt;getKeyValue($key, 'w');     }      \/**      * @param string $key      * @return string      * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0443 \u0438\u0437 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f      *\/     public function m(string $key) : string {         return $this-&gt;getKeyValue($key, 'm');     }      \/**      * @param string $key      * @param string $type      * @return string      * \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u044b\u0431\u043e\u0440\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f      * \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0430. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0438\u0437 \u0440\u0435\u0434\u0438\u0441\u0430 \u0438\u043b\u0438 \u0435\u0449\u0435 \u043e\u0442\u043a\u0443\u0434\u0430-\u0442\u043e.      *\/     private function getKeyValue ( string &$key, string $type ) : string {         try{             if(!$key=trim($key))                 throw new LanguageException(&quot;Error dictionary &quot;.addslashes($key).&quot;. The &quot;.addslashes($key).&quot; can not be empty or contain only whitespace.&quot;, 777001);              if($this-&gt;storageStatus)                 $value = $this-&gt;storageConnection-&gt;executeCommand(&quot;GET&quot;,[&quot;KEY&quot; =&gt;$this-&gt;getKeyMD5($type,$key)]);             else{                 $value = @$this-&gt;$type[$this-&gt;getKeyMD5($type,$key)];             }                              \/*\u043f\u043e\u0432\u0435\u0441\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a if(!$value){                 if ($this-&gt;hasEventHandlers(\\yii\\i18n\\MessageSource::EVENT_MISSING_TRANSLATION)) {                     $event = new \\yii\\i18n\\MissingTranslationEvent([                         'category' =&gt; $key,                         'message' =&gt; $key,                         'language' =&gt; $this-&gt;language,                     ]);                     $this-&gt;trigger(\\yii\\i18n\\MessageSource::EVENT_MISSING_TRANSLATION, $event);                  }             }*\/             return $value ? $value : $key;         }catch (\\Exception $event){             return $key;         }     }        \/**      * @param $key      * @return bool      * \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043b\u044e\u0447      *\/     public function del($key):bool{         try{              if($this-&gt;storageConnection-&gt;isActive){                 return $this-&gt;storageConnection-&gt;executeCommand(&quot;DEL&quot;,[&quot;KEY&quot; =&gt;$key]);\/\/ keys test:1:v             }else{                 list($lang_key,$type,$key_)= explode(&quot;:&quot;, $key);                 if(method_exists($this, $type) && isset($this-&gt;$type[$key_])){                     unset($this-&gt;$type[$key_]);                     return true;                 }                 return false;              }         }catch (\\Exception $event){             return false;         }     }      \/**      * @param string $lang_key      * @param null $type      * @return bool      * \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043b\u044e\u0447\u0438 \u043f\u043e \u044f\u0437\u044b\u043a\u0443 \u0442\u0438\u043f\u0430 \u0438\u043b\u0438 \u0432\u0441\u0435\u0433\u043e \u044f\u0437\u044b\u043a\u0430      *\/     public function delAll(string $lang_key,$type=null){         try{             if($this-&gt;storageConnection-&gt;isActive){                    $keys= $this-&gt;keys($lang_key,$type);                     if(!empty($keys)){                         foreach ($keys as $key){                             $this-&gt;del($key);                         }                         if($type==null) $this-&gt;del($lang_key.&quot;:index&quot;);                     }             }else{                 $this-&gt;w=$this-&gt;m=[];                     return true;             }          }catch (\\Exception $event){             return false;         }     }       \/**      * @param $type      * @param $key      * @return array      * \u0412\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0431\u043b\u043e\u043a\u0430      *\/     public function keys(string $lang_key,$type=null):array{         try{              if($this-&gt;storageConnection-&gt;isActive){                 if($type!=null)                     return $this-&gt;storageConnection-&gt;executeCommand(&quot;KEYS&quot;,[&quot;KEY&quot; =&gt; $lang_key.&quot;:&quot;.$type.&quot;:*&quot;]);\/\/ keys test:1:*                 else                     return $this-&gt;storageConnection-&gt;executeCommand(&quot;KEYS&quot;,[&quot;KEY&quot; =&gt; $lang_key.&quot;:*&quot;]);             }else{                                  if($type!=null){                     return   $this-&gt;w+$this-&gt;m;                 }else{                     if(method_exists($this, $type))return $this-&gt;$type;                 }                 return [];             }          }catch (\\Exception $event){             return [];         }     }        \/**      * @param $type      * @param $key      * @return bool      * \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430      *\/     public function exists($key):bool{         try{             if($this-&gt;storageConnection-&gt;isActive){                  return $this-&gt;storageConnection-&gt;executeCommand(&quot;EXISTS&quot;,[&quot;KEY&quot; =&gt;$key]);              }else{                 \/\/ return (method_exists($this, $type) && isset($this-&gt;$type[$key]));                 list($lang_key,$type,$key_)= explode(&quot;:&quot;, $key);                 if(method_exists($this, $type))return isset($this-&gt;$type[$key_]);                 return false;             }             return false;         }catch (\\Exception $event){             return false;         }      }    } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h4>\u0421\u0443\u0442\u044c<\/h4>\n<p>  \u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u044f\u0437\u044b\u043a\u0430 \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u043c\u0443 <code> Yii::$app-&gt;language <\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u044f\u0437\u044b\u043a\u0430, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 COOKIE \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 Redis \u0438\u043b\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0435\u0441\u043b\u0438 Redis \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u043f\u043e \u0442\u0438\u043f\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code> $this-&gt;w[] \u0441\u043b\u043e\u0432\u043e ,$this-&gt;m[] \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435<\/code>. \u041d\u043e \u044d\u0442\u043e \u043c\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0430 \u0443 \u0432\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0431\u0443\u0444\u0435\u0440\u0435.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h4>\n<p>  \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u043d\u043d\u0435\u043a\u0442 Redis. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442 \u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u0443\u0444\u0435\u0440, \u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c \u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0435\u0433\u043e, \u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 MySQL.<\/p>\n<p>  \u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043c\u044b \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u043b\u0438 \u044f\u0437\u044b\u043a \u0443\u0436\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043f\u0443\u0442\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u0435\u0444\u043e\u043b\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 <code>ru-RU:index<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<p>  \u0418 \u0442\u0430\u043a, \u0432 MySQL \u0435\u0441\u0442\u044c 4 \u044f\u0437\u044b\u043a\u0430. \u0418\u0434\u0443\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u044b \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 ru-RU \u044f\u0437\u044b\u043a, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c? \u041c\u044b \u0433\u0440\u0443\u0437\u0438\u043c Redis \u0438\u0437 MySQL \u0432\u0435\u0441\u044c ru-RU \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0442\u0430\u043c \u043d\u0435\u0442 \u0438 \u0440\u0430\u0437\u0434\u0430\u0435\u043c \u0435\u0433\u043e, \u0434\u0430\u043b\u0435\u0435 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u043d\u0435\u043a\u0442 \u043d\u0430 en-US, \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0432 Redis \u0438 \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0434\u0432\u0430 \u044f\u0437\u044b\u043a\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043e.<\/p>\n<p>  \u0416\u0438\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u0435\u0447\u043d\u043e \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043a\u043b\u044e\u0447<\/p>\n<pre><code class=\"php\">$redis-&gt;executeCommand('SETEX', [&quot;KEY&quot; =&gt; $this-&gt;getKeyMD5($data['type'],$data['key']),&quot;SECONDS&quot;=&gt;$this-&gt;expire,&quot;VALUE&quot;=&gt; $data['translator']]);<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412\u0438\u0434\u0436\u0435\u0442 \u0441\u043c\u0435\u043d\u044b \u044f\u0437\u044b\u043a\u0430<\/h2>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">frontend\\widgets\\WLang<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">namespace frontend\\widgets\\WLang; use frontend\\models\\Lang; use Yii; use PDO;  class WLang extends \\yii\\bootstrap\\Widget {     public function init(){}      public function run() {         return $this-&gt;render('index', [             'current' =&gt; \\common\\components\\LanguageExtension::currentLang(),             'default' =&gt; \\Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT `id`, `code_lang`, `local`, `name`, `default_lang`, `status` FROM `gr_language` WHERE local=:local LIMIT 1&quot;)-&gt;bindValue(&quot;:local&quot;,\\common\\components\\LanguageExtension::currentLang(),PDO::PARAM_STR)-&gt;queryOne(PDO::FETCH_OBJ),             'langs' =&gt;\\Yii::$app-&gt;db-&gt;createCommand(&quot;SELECT `id`, `code_lang`, `local`, `name`, `default_lang`, `status` FROM `gr_language` WHERE 1&quot;)-&gt;queryAll(PDO::FETCH_OBJ),         ]);     } }         &lt;div&gt; &lt;?php use yii\\helpers\\Html; ?&gt;     &lt;script&gt;          function click_(el) {             var lang = $(el).attr('data-lang');              var date = new Date;             date.setDate(date.getDate() + 1);             document.cookie = &quot;userLang=&quot; + lang + &quot;; path=\/; expires=&quot; + date.toUTCString() + &quot;;&quot;;             location.reload();         }         &lt;\/script&gt;  &lt;div id=&quot;lang&quot;&gt;     &lt;span id=&quot;current-lang&quot;&gt;         &lt;span class=&quot;show-more-lang&quot; &gt;\u0422\u0435\u043a\u0443\u0449\u0438\u0439 \u044f\u0437\u044b\u043a &lt;?= $current;?&gt;&lt;\/span&gt;     &lt;\/span&gt;     &lt;ul id=&quot;langs&quot;&gt;         &lt;?php foreach ($langs as $lang):?&gt;             &lt;li class=&quot;item-lang&quot;&gt;&lt;a href=&quot;#&quot; onclick=&quot;click_(this)&quot; data-lang=&quot;&lt;?=$lang-&gt;local?&gt;&quot;&gt;&lt;?=$lang-&gt;code_lang?&gt;&lt;\/a&gt;&lt;\/li&gt;         &lt;?php endforeach;?&gt;     &lt;\/ul&gt; &lt;\/div&gt;   &lt;\/div&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0441\u044f \u0441\u0443\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u2014 \u044d\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u044f\u0437\u044b\u043a\u0438 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c COOKIE \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u044f\u0442\u0441\u044f \u0435\u0449\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044b \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u0431\u043e\u0440 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u0432\u043d\u043e\u0441\u0438\u043c \u0432 MySQL \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <b>good luck, <a href=\"https:\/\/habrahabr.ru\/users\/jekshmek\/\" class=\"user_link\">Jekshmek<\/a><\/b><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/318102\/\"> https:\/\/habrahabr.ru\/post\/318102\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 Yii2 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>  <b>1.<\/b> \u0424\u0430\u0439\u043b \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, \u0432\u0438\u0434\u0430: \u043a\u043b\u044e\u0447=&gt;\u043f\u0435\u0440\u0435\u0432\u043e\u0434 (\u0433\u0438\u0431\u043a\u043e);<br \/>  <b>2.<\/b> \u0424\u0430\u0439\u043b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c .po,.mo \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 (\u043d\u0443\u0436\u0435\u043d \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0431\u044b\u0441\u0442\u0440\u043e);<br \/>  <b>3.<\/b> \u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 mysql, \u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c (\u043b\u0443\u0447\u0448\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u0438\u043b\u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0442\u0430\u043a \u043a\u0430\u043a yii \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043f\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 );<\/p>\n<p>  \u0418\u043b\u0438 \u0441\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u0437\u044f\u0432 \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u0432 \u0431\u0430\u0437\u0435 \u043d\u043e \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c (\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u0438 \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f).<\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435<\/h3>\n<p>  \u0412\u044b\u0437\u043e\u0432 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c Yii::t(). \u0425\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044b \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u043c \u0432 MySQL. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u044f\u0437\u044b\u043a\u0443 \u0431\u0443\u0434\u0435\u0442 \u0432 Redis. \u0421\u0431\u043e\u0440 \u043a\u043b\u044e\u0447\u0435\u0439 (\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439) \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0438\u043c.<\/p>\n<h4>\u0412 \u0447\u0435\u043c \u043f\u043b\u044e\u0441\u044b:<\/h4>\n<p>  <\/p>\n<ul>\n<li> \u0431\u044b\u0441\u0442\u0440\u0435\u0435;<\/li>\n<li> \u0433\u0438\u0431\u0447\u0435;<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-282803","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=282803"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282803\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}