Class ExtractTask
Language string extractor
- AppShell
- ExtractTask
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/ExtractTask.php
Properties summary
-
$_exclude
protectedarray
An array of directories to exclude. -
$_extractCore
protectedboolean
Holds whether this call should extract the CakePHP Lib messages -
$_extractValidation
protectedboolean
Holds whether this call should extract model validation messages -
$_file
protectedstring
Current file being processed -
$_files
protectedarray
Files from where to extract -
$_merge
protectedboolean
Merge all domain and category strings into the default.pot file -
$_output
protectedstring
Destination path -
$_paths
protectedstring
Paths to use when looking for strings -
$_storage
protectedstring
Contains all content waiting to be write -
$_tokens
protectedarray
Extracted tokens -
$_translations
protectedarray
Extracted strings indexed by category and domain. -
$_validationDomain
protectedboolean
Holds the validation string domain to use for validation messages when extracting
Method Summary
-
_addTranslation() protected
Add a translation to the internal translations property -
_buildFiles() protected
Build the translate template file contents out of obtained strings -
_extract() protected
Extract text -
_extractPluginValidationMessages() protected
Extract validation messages from application or plugin models -
_extractTokens() protected
Extract 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() protected
Format a string to be added as a translatable string -
_getPaths() protected
Method to interact with the User and get path selections. -
_getStrings() protected
Get 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() protected
Checks whether or not a given path is usable for writing. -
_markerError() protected
Indicate an invalid marker on a processed file -
_parse() protected
Parse tokens -
_processValidationRules() protected
Process a validation rule for a field and looks for a message to be added to the translation map
-
_searchFiles() protected
Search files that may contain translatable strings -
_store() protected
Prepare a file to be stored -
_writeFiles() protected
Write the files that need to be stored -
_writeHeader() protected
Build the translation template header -
execute() public
Execution method always used for tasks -
getOptionParser() public
Gets the option parser instance and configures it.
Method Detail
_addTranslation() 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() protected ¶
_buildFiles( )
Build the translate template file contents out of obtained strings
_extractPluginValidationMessages() 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() protected ¶
_extractValidationMessages( )
Looks for models in the application and extracts the validation messages to be added to the translation map
_formatString() protected ¶
_formatString( string $string )
Format a string to be added as a translatable string
Parameters
- string $string
- String to format
Returns
Formatted string
_getStrings() 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
Strings extracted
_isExtractingApp() 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
_isPathUsable() protected ¶
_isPathUsable( string $path )
Checks whether or not a given path is usable for writing.
Parameters
- string $path
- Path to folder
Returns
true if it exists and is writable, false otherwise
_markerError() 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() 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() 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() 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() protected ¶
_writeHeader( )
Build the translation template header
Returns
Translation template header
Properties detail
$_extractCore ¶
Holds whether this call should extract the CakePHP Lib messages
false
$_extractValidation ¶
Holds whether this call should extract model validation messages
true
$_validationDomain ¶
Holds the validation string domain to use for validation messages when extracting
'default'