W3cubDocs

/Symfony 4.1

PhpExtractor

class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface

PhpExtractor extracts translation messages from a PHP template.

Constants

MESSAGE_TOKEN
METHOD_ARGUMENTS_TOKEN
DOMAIN_TOKEN

Properties

protected array $sequences The sequence that captures translation messages.

Methods

array extractFiles(string|array $resource) from AbstractFileExtractor
bool isFile(string $file) from AbstractFileExtractor
bool canBeExtracted(string $file)
array extractFromDirectory(string|array $directory)
extract(string|array $resource, MessageCatalogue $catalog)

Extracts translation messages from files, a file or a directory to the catalogue.

setPrefix(string $prefix)

Sets the prefix that should be used for new found messages.

string normalizeToken(mixed $token)

Normalizes a token.

parseTokens(array $tokens, MessageCatalogue $catalog)

Extracts trans message from PHP tokens.

Details

protected array extractFiles(string|array $resource)

Parameters

string|array $resource Files, a file or a directory

Return Value

array

protected bool isFile(string $file)

Parameters

string $file

Return Value

bool

Exceptions

InvalidArgumentException

protected bool canBeExtracted(string $file)

Parameters

string $file

Return Value

bool

Exceptions

InvalidArgumentException

protected array extractFromDirectory(string|array $directory)

Parameters

string|array $directory

Return Value

array files to be extracted

extract(string|array $resource, MessageCatalogue $catalog)

Extracts translation messages from files, a file or a directory to the catalogue.

Parameters

string|array $resource Files, a file or a directory
MessageCatalogue $catalog

setPrefix(string $prefix)

Sets the prefix that should be used for new found messages.

Parameters

string $prefix The prefix

protected string normalizeToken(mixed $token)

Normalizes a token.

Parameters

mixed $token

Return Value

string

protected parseTokens(array $tokens, MessageCatalogue $catalog)

Extracts trans message from PHP tokens.

Parameters

array $tokens
MessageCatalogue $catalog

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Translation/Extractor/PhpExtractor.html