Class ExtractTask

Language string extractor

AppShell
Extended by ExtractTask
Package: Cake\Console\Command\Task
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/ExtractTask.php

Properties summary

  • $_exclude protected
    array
    An array of directories to exclude.
  • $_extractCore protected
    boolean
    Holds whether this call should extract the CakePHP Lib messages
  • boolean
    Holds whether this call should extract model validation messages
  • $_file protected
    string
    Current file being processed
  • $_files protected
    array
    Files from where to extract
  • $_merge protected
    boolean
    Merge all domain and category strings into the default.pot file
  • $_output protected
    string
    Destination path
  • $_paths protected
    string
    Paths to use when looking for strings
  • $_storage protected
    string
    Contains all content waiting to be write
  • $_tokens protected
    array
    Extracted tokens
  • $_translations protected
    array
    Extracted strings indexed by category, domain, msgid and context.
  • $_validationDomain protected
    boolean
    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
  • Extract validation messages from application or plugin models
  • _extractTokens() protected
    Extract tokens out of all files to be processed
  • 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
  • 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
  • Gets 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

_extract()source protected

_extract( )

Extract text

_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

_extractTokens()source protected

_extractTokens( )

Extract tokens out of all files to be processed

_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

string
Formatted string

_getPaths()source protected

_getPaths( )

Method to interact with the User and get path selections.

_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

array
Strings 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

boolean
true 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

_searchFiles()source protected

_searchFiles( )

Search files that may contain translatable strings

_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.

_writeFiles()source protected

_writeFiles( )

Write the files that need to be stored

_writeHeader()source protected

_writeHeader( )

Build the translation template header

Returns

string
Translation template header

execute()source public

execute( )

Execution method always used for tasks

getOptionParser()source public

getOptionParser( )

Gets the option parser instance and configures it.

Returns

ConsoleOptionParser

Properties detail

$_excludesource

protected array

An array of directories to exclude.

array()

$_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

$_filesource

protected string

Current file being processed

null

$_filessource

protected array

Files from where to extract

array()

$_mergesource

protected boolean

Merge all domain and category strings into the default.pot file

false

$_outputsource

protected string

Destination path

null

$_pathssource

protected string

Paths to use when looking for strings

array()

$_storagesource

protected string

Contains all content waiting to be write

array()

$_tokenssource

protected array

Extracted tokens

array()

$_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