Property | Type | Description | |
---|---|---|---|
$catalog | name of the file that will be used for translations for "po" format. | ||
$db | connection component ID for "db" format. | ||
$defaultAction | controller default action ID. | ||
$except | list of patterns that specify which files/directories should NOT be processed. If empty or not set, all files/directories will be processed. See helpers/FileHelper::findFiles() description for pattern matching rules. If a file/directory matches both a pattern in "only" and "except", it will NOT be processed. | ||
$format | generated file format. Can be "php", "db" or "po". | ||
$ignoreCategories | message categories to ignore. For example, 'yii', 'app*', 'widgets/menu', etc. | ||
$languages | required, list of language codes that the extracted messages should be translated to. For example, ['zh-CN', 'de']. | ||
$markUnused | whether to mark messages that no longer appear in the source code. Defaults to true, which means each of these messages will be enclosed with a pair of '@@' marks. | ||
$messagePath | required, root directory containing message translations. | ||
$messageTable | custom name for translation message table for "db" format. | ||
$only | list of patterns that specify which files (not directories) should be processed. If empty or not set, all files will be processed. See helpers/FileHelper::findFiles() description for pattern matching rules. If a file/directory matches both a pattern in "only" and "except", it will NOT be processed. | ||
$overwrite | whether the message file should be overwritten with the merged messages | ||
$removeUnused | whether to remove messages that no longer appear in the source code. Defaults to false, which means these messages will NOT be removed. | ||
$sort | whether to sort messages by keys when merging new messages with the existing ones. Defaults to false, which means the new (untranslated) messages will be separated from the old (translated) ones. | ||
$sourceMessageTable | custom name for source message table for "db" format. | ||
$sourcePath | required, root directory of all source files. | ||
$translator | the name of the function for translating messages. Defaults to 'Yii::t'. This is used as a mark to find the messages to be translated. You may use a string for single function name or an array for multiple function names. |
Method | Description | |
---|---|---|
actionConfig ( string $filePath ) : integer | Creates a configuration file for the "extract" command using command line options specified | |
actionConfigTemplate ( string $filePath ) : integer | Creates a configuration file template for the "extract" command. | |
actionExtract ( string $configFile = null ) | Extracts messages to be translated from source code. | |
optionAliases ( ) | ||
options ( $actionID ) |
Method | Description | |
---|---|---|
extractMessages ( string $fileName, string $translator, array $ignoreCategories = [] ) : array | Extracts messages from a file | |
getLine ( array $tokens ) : integer | string | Finds out a line of the first non-char PHP token found | |
isCategoryIgnored ( string $category, array $ignoreCategories ) : boolean | The method checks, whether the $category is ignored according to $ignoreCategories array. | |
saveMessagesCategoryToPHP ( array $messages, string $fileName, boolean $overwrite, boolean $removeUnused, boolean $sort, string $category, boolean $markUnused ) : integer | Writes category messages into PHP file | |
saveMessagesToDb ( array $messages, |
Saves messages to database | |
saveMessagesToPHP ( array $messages, string $dirName, boolean $overwrite, boolean $removeUnused, boolean $sort, boolean $markUnused ) | Writes messages into PHP files | |
saveMessagesToPO ( array $messages, string $dirName, boolean $overwrite, boolean $removeUnused, boolean $sort, string $catalog, boolean $markUnused ) | Writes messages into PO file | |
saveMessagesToPOT ( array $messages, string $dirName, string $catalog ) | Writes messages into POT file | |
tokensEqual ( array | string $a, array | string $b ) : boolean | Finds out if two PHP tokens are equal |
Method | Description | |
---|---|---|
extractMessagesFromTokens ( array $tokens, array $translatorTokens, array $ignoreCategories ) : array | Extracts messages from a parsed PHP tokens list. |
public actionConfig ( string $filePath ) : integer | ||
$filePath | string | output file name or alias. |
return | integer | CLI exit code |
public actionConfigTemplate ( string $filePath ) : integer | ||
$filePath | string | output file name or alias. |
return | integer | CLI exit code |
public actionExtract ( string $configFile = null ) | ||
$configFile | string | 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. |
protected extractMessages ( string $fileName, string $translator, array $ignoreCategories = [] ) : array | ||
$fileName | string | name of the file to extract messages from |
$translator | string | name of the function used to translate messages |
$ignoreCategories | array | message categories to ignore. This parameter is available since version 2.0.4. |
return | array |
protected saveMessagesCategoryToPHP ( array $messages, string $fileName, boolean $overwrite, boolean $removeUnused, boolean $sort, string $category, boolean $markUnused ) : integer | ||
$messages | array | |
$fileName | string | name of the file to write to |
$overwrite | boolean | if existing file should be overwritten without backup |
$removeUnused | boolean | if obsolete translations should be removed |
$sort | boolean | if translations should be sorted |
$category | string | message category |
$markUnused | boolean | if obsolete translations should be marked |
return | integer | exit code |
protected saveMessagesToDb ( array $messages, |
||
$messages | array | |
$db | ||
$sourceMessageTable | string | |
$messageTable | string | |
$removeUnused | boolean | |
$languages | array | |
$markUnused | boolean |
protected saveMessagesToPHP ( array $messages, string $dirName, boolean $overwrite, boolean $removeUnused, boolean $sort, boolean $markUnused ) | ||
$messages | array | |
$dirName | string | name of the directory to write to |
$overwrite | boolean | if existing file should be overwritten without backup |
$removeUnused | boolean | if obsolete translations should be removed |
$sort | boolean | if translations should be sorted |
$markUnused | boolean | if obsolete translations should be marked |
protected saveMessagesToPO ( array $messages, string $dirName, boolean $overwrite, boolean $removeUnused, boolean $sort, string $catalog, boolean $markUnused ) | ||
$messages | array | |
$dirName | string | name of the directory to write to |
$overwrite | boolean | if existing file should be overwritten without backup |
$removeUnused | boolean | if obsolete translations should be removed |
$sort | boolean | if translations should be sorted |
$catalog | string | message catalog |
$markUnused | boolean | if obsolete translations should be marked |
public $catalog |
public $except |
public $ignoreCategories |
public $languages |
public $markUnused |
public $messagePath |
public $messageTable |
public $only |
public $overwrite |
public $removeUnused |
public $sort |
public $sourceMessageTable |