PHP 클래스 yii\console\controllers\MessageController

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
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\console\Controller
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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.

공개 메소드들

메소드 설명
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 )

보호된 메소드들

메소드 설명
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, Connection $db, string $sourceMessageTable, string $messageTable, boolean $removeUnused, array $languages, boolean $markUnused ) 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

비공개 메소드들

메소드 설명
extractMessagesFromTokens ( array $tokens, array $translatorTokens, array $ignoreCategories ) : array Extracts messages from a parsed PHP tokens list.

메소드 상세

actionConfig() 공개 메소드

The generated configuration file contains parameters required for source code messages extraction. You may use this configuration file with the "extract" command.
public actionConfig ( string $filePath ) : integer
$filePath string output file name or alias.
리턴 integer CLI exit code

actionConfigTemplate() 공개 메소드

The created configuration file contains detailed instructions on how to customize it to fit for your needs. After customization, you may use this configuration file with the "extract" command.
public actionConfigTemplate ( string $filePath ) : integer
$filePath string output file name or alias.
리턴 integer CLI exit code

actionExtract() 공개 메소드

This command will search through source code files and extract messages that need to be translated in different languages.
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.

extractMessages() 보호된 메소드

Extracts messages from a file
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.
리턴 array

getLine() 보호된 메소드

Finds out a line of the first non-char PHP token found
부터: 2.0.1
protected getLine ( array $tokens ) : integer | string
$tokens array
리턴 integer | string

isCategoryIgnored() 보호된 메소드

Examples: - myapp - will be ignored only myapp category; - myapp* - will be ignored by all categories beginning with myapp (myapp, myapplication, myapprove, myapp/widgets, myapp.widgets, etc).
부터: 2.0.7
protected isCategoryIgnored ( string $category, array $ignoreCategories ) : boolean
$category string category that is checked
$ignoreCategories array message categories to ignore.
리턴 boolean

optionAliases() 공개 메소드

부터: 2.0.8
public optionAliases ( )

options() 공개 메소드

public options ( $actionID )

saveMessagesCategoryToPHP() 보호된 메소드

Writes category messages into PHP file
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
리턴 integer exit code

saveMessagesToDb() 보호된 메소드

Saves messages to database
protected saveMessagesToDb ( array $messages, Connection $db, string $sourceMessageTable, string $messageTable, boolean $removeUnused, array $languages, boolean $markUnused )
$messages array
$db yii\db\Connection
$sourceMessageTable string
$messageTable string
$removeUnused boolean
$languages array
$markUnused boolean

saveMessagesToPHP() 보호된 메소드

Writes messages into PHP files
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

saveMessagesToPO() 보호된 메소드

Writes messages into PO file
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

saveMessagesToPOT() 보호된 메소드

Writes messages into POT file
부터: 2.0.6
protected saveMessagesToPOT ( array $messages, string $dirName, string $catalog )
$messages array
$dirName string name of the directory to write to
$catalog string message catalog

tokensEqual() 보호된 메소드

Finds out if two PHP tokens are equal
부터: 2.0.1
protected tokensEqual ( array | string $a, array | string $b ) : boolean
$a array | string
$b array | string
리턴 boolean

프로퍼티 상세

$catalog 공개적으로 프로퍼티

name of the file that will be used for translations for "po" format.
public $catalog

$db 공개적으로 프로퍼티

connection component ID for "db" format.
public $db

$defaultAction 공개적으로 프로퍼티

controller default action ID.
public $defaultAction

$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.
public $except

$format 공개적으로 프로퍼티

generated file format. Can be "php", "db" or "po".
public $format

$ignoreCategories 공개적으로 프로퍼티

message categories to ignore. For example, 'yii', 'app*', 'widgets/menu', etc.
또한 보기: isCategoryIgnored
public $ignoreCategories

$languages 공개적으로 프로퍼티

required, list of language codes that the extracted messages should be translated to. For example, ['zh-CN', 'de'].
public $languages

$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.
public $markUnused

$messagePath 공개적으로 프로퍼티

required, root directory containing message translations.
public $messagePath

$messageTable 공개적으로 프로퍼티

custom name for translation message table for "db" format.
public $messageTable

$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.
public $only

$overwrite 공개적으로 프로퍼티

whether the message file should be overwritten with the merged messages
public $overwrite

$removeUnused 공개적으로 프로퍼티

whether to remove messages that no longer appear in the source code. Defaults to false, which means these messages will NOT be removed.
public $removeUnused

$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.
public $sort

$sourceMessageTable 공개적으로 프로퍼티

custom name for source message table for "db" format.
public $sourceMessageTable

$sourcePath 공개적으로 프로퍼티

required, root directory of all source files.
public $sourcePath

$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.
public $translator