On this page
Class ExtractTask
Language string extractor
- AppShell
ExtractTask
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/ExtractTask.php
Properties summary
-
$_exclude
protectedarray
-
$_extractCore
protectedboolean
-
$_extractValidation
protectedboolean
-
$_file
protectedstring
-
$_files
protectedarray
-
$_merge
protectedboolean
-
$_output
protectedstring
-
$_paths
protectedstring
-
$_storage
protectedstring
-
$_tokens
protectedarray
-
$_translations
protectedarray
-
$_validationDomain
protectedboolean
Method Summary
-
_addTranslation() protectedAdd a translation to the internal translations property
-
_buildFiles() protectedBuild the translate template file contents out of obtained strings
-
_extract() protectedExtract text
-
_extractPluginValidationMessages() protectedExtract validation messages from application or plugin models
-
_extractTokens() protectedExtract tokens out of all files to be processed
-
_extractValidationMessages() protected
Looks for models in the application and extracts the validation messages to be added to the translation map
-
_formatString() protectedFormat a string to be added as a translatable string
-
_getPaths() protectedMethod to interact with the User and get path selections.
-
_getStrings() protectedGet the strings from the position forward
-
_isExtractingApp() protected
Returns whether this execution is meant to extract string only from directories in folder represented by the APP constant, i.e. this task is extracting strings from same application.
-
_isPathUsable() protectedChecks whether or not a given path is usable for writing.
-
_markerError() protectedIndicate an invalid marker on a processed file
-
_parse() protectedParse tokens
-
_processValidationRules() protected
Process a validation rule for a field and looks for a message to be added to the translation map
-
_searchFiles() protectedSearch files that may contain translatable strings
-
_store() protectedPrepare a file to be stored
-
_writeFiles() protectedWrite the files that need to be stored
-
_writeHeader() protectedBuild the translation template header
-
execute() publicExecution method always used for tasks
-
getOptionParser() publicGets the option parser instance and configures it.
Method Detail
_addTranslation()source protected
_addTranslation( string $category , string $domain , string $msgid , array $details array() )
Add a translation to the internal translations property
Takes care of duplicate translations
Parameters
-
string
$category
- The category
-
string
$domain
- The domain
-
string
$msgid
- The message string
-
array
$details
optional array() - The file and line references
_buildFiles()source protected
_buildFiles( )
Build the translate template file contents out of obtained strings
_extractPluginValidationMessages()source protected
_extractPluginValidationMessages( string $plugin null )
Extract validation messages from application or plugin models
Parameters
-
string
$plugin
optional null -
Plugin name or
null
to process application models
_extractValidationMessages()source protected
_extractValidationMessages( )
Looks for models in the application and extracts the validation messages to be added to the translation map
_formatString()source protected
_formatString( string $string )
Format a string to be added as a translatable string
Parameters
-
string
$string
- String to format
Returns
stringFormatted string
_getStrings()source protected
_getStrings( integer $position , integer $target )
Get the strings from the position forward
Parameters
-
integer
$position
- $position Actual position on tokens array
-
integer
$target
- Number of strings to extract
Returns
arrayStrings extracted
_isExtractingApp()source protected
_isExtractingApp( )
Returns whether this execution is meant to extract string only from directories in folder represented by the APP constant, i.e. this task is extracting strings from same application.
Returns
boolean_isPathUsable()source protected
_isPathUsable( string $path )
Checks whether or not a given path is usable for writing.
Parameters
-
string
$path
- Path to folder
Returns
booleantrue if it exists and is writable, false otherwise
_markerError()source protected
_markerError( string $file , integer $line , string $marker , integer $count )
Indicate an invalid marker on a processed file
Parameters
-
string
$file
- File where invalid marker resides
-
integer
$line
- Line number
-
string
$marker
- Marker found
-
integer
$count
- Count
_parse()source protected
_parse( string $functionName , array $map )
Parse tokens
Parameters
-
string
$functionName
- Function name that indicates translatable string (e.g: '__')
-
array
$map
- Array containing what variables it will find (e.g: category, domain, singular, plural)
_processValidationRules()source protected
_processValidationRules( string $field , array $rules , string $file , string $domain , string $category 'LC_MESSAGES' )
Process a validation rule for a field and looks for a message to be added to the translation map
Parameters
-
string
$field
- the name of the field that is being processed
-
array
$rules
- the set of validation rules for the field
-
string
$file
- the file name where this validation rule was found
-
string
$domain
- default domain to bind the validations to
-
string
$category
optional 'LC_MESSAGES' - the translation category
_store()source protected
_store( string $category , string $domain , string $header , string $sentence )
Prepare a file to be stored
Parameters
-
string
$category
- The category
-
string
$domain
- The domain
-
string
$header
- The header content.
-
string
$sentence
- The sentence to store.
_writeHeader()source protected
_writeHeader( )
Build the translation template header
Returns
stringTranslation template header
getOptionParser()source public
getOptionParser( )
Gets the option parser instance and configures it.
Returns
ConsoleOptionParser
Properties detail
$_extractCoresource
protected boolean
Holds whether this call should extract the CakePHP Lib messages
false
$_extractValidationsource
protected boolean
Holds whether this call should extract model validation messages
true
$_mergesource
protected boolean
Merge all domain and category strings into the default.pot file
false
$_translationssource
protected array
Extracted strings indexed by category, domain, msgid and context.
array()
$_validationDomainsource
protected boolean
Holds the validation string domain to use for validation messages when extracting
'default'
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.10/class-ExtractTask.html