function _potx_find_twig_trans_context in Translation template extractor 8
Same name and namespace in other branches
- 6.3 potx.inc \_potx_find_twig_trans_context()
- 7.3 potx.inc \_potx_find_twig_trans_context()
- 7.2 potx.inc \_potx_find_twig_trans_context()
Look for a 'context' parameter in {% trans %} tags.
The 'context' parameter appears after the 'with' keyword.
1 call to _potx_find_twig_trans_context()
- _potx_process_twig_trans_tag in ./
potx.inc - Parses a single {% trans %} tag, and extracts the translatable string.
File
- ./
potx.inc, line 2192 - Extraction API used by the web and command line interface.
Code
function _potx_find_twig_trans_context($stream) {
$token = $stream
->next();
if ($token
->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
while (!$stream
->isEOF() && ($token = $stream
->next()) && !$token
->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
if ($token
->test(Twig_Token::STRING_TYPE, 'context')) {
// Skip the ':' character.
$stream
->next();
$token = $stream
->next();
if ($token
->test(Twig_Token::STRING_TYPE)) {
return $token
->getValue();
}
}
}
}
return POTX_CONTEXT_NONE;
}