The extracted messages can be saved the following depending on format setting in config file: - PHP message source files. - ".po" files. - Database. Usage: 1. Create a configuration file using the 'message/config' command: yii message/config /path/to/myapp/messages/config.php 2. Edit the created config file, adjusting it for your web application needs. 3. Run the 'message/extract' command, using created config: yii message /path/to/myapp/messages/config.php
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends yii\console\Controller
Example #1
0
 protected function extractMessages($fileName, $translator)
 {
     $messages = parent::extractMessages($fileName, $translator);
     if (!empty($messages)) {
         echo 'Found messages: ' . print_r($messages, true);
     }
     try {
         $fileContent = file_get_contents($fileName);
         $markerFound = $this->findMarker($fileContent);
         if ($markerFound) {
             $fqn = $this->extractClassname($fileName, $fileContent);
             $arMessages = $this->loadMessages($fqn);
             $messages[$fqn] = $arMessages;
             if (!empty($arMessages)) {
                 echo 'Added arMessages: ' . print_r($messages, true);
             }
         }
     } catch (\Exception $ex) {
         $msg = $ex->getMessage();
         echo "  error: '{$msg}'\n";
     }
     return $messages;
 }
 /**
  * @inheritdoc Initialise the $files static array.
  */
 public function init()
 {
     if (empty(self::$files[static::EXTENSION]) && in_array(static::EXTENSION, $this->module->patterns)) {
         self::$files[static::EXTENSION] = FileHelper::findFiles(realpath($this->_getRoot()), ['except' => $this->module->ignoredItems, 'only' => [static::EXTENSION]]);
     }
     parent::init();
 }
 /**
  * @inheritdoc Initialise the $files static array.
  */
 public function init()
 {
     $this->initFiles();
     parent::init();
 }