1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-18 04:22:10 +02:00
This commit is contained in:
Ryan Cramer
2020-04-15 15:37:37 -04:00
parent b79c5c0e45
commit 64bb5b09ce

View File

@@ -219,30 +219,38 @@ class LanguageParser extends Wire {
$this->findArrayTranslations($data); $this->findArrayTranslations($data);
// Find $this->_('text') style matches // Find $this->_('text') style matches
preg_match_all( '/(>_)\(\s*' . // $this->_( preg_match_all(
'/(>_)\(\s*' . // $this->_(
'([\'"])(.+?)(?<!\\\\)\\2' . // "text" '([\'"])(.+?)(?<!\\\\)\\2' . // "text"
'\s*\)+(.*)$/m', // and everything else '\s*\)+(.*)$/m', // and everything else
$data, $matches[1]); $data, $matches[1]
);
// Find __('text', textdomain) style matches // Find __('text', textdomain) style matches
preg_match_all( '/([\s.=(]__|^__)\(\s*' . // __( preg_match_all(
'/([\s.=(\\\\]__|^__)\(\s*' . // __(
'([\'"])(.+?)(?<!\\\\)\\2\s*' . // "text" '([\'"])(.+?)(?<!\\\\)\\2\s*' . // "text"
'(?:,\s*[^)]+)?\)+(.*)$/m', // , textdomain (optional) and everything else '(?:,\s*[^)]+)?\)+(.*)$/m', // , textdomain (optional) and everything else
$data, $matches[2]); $data, $matches[2]
);
// Find _x('text', 'context', textdomain) or $this->_x('text', 'context') style matches // Find _x('text', 'context', textdomain) or $this->_x('text', 'context') style matches
preg_match_all( '/([\s.=>(]_x|^_x)\(\s*' . // _x( or $this->_x( preg_match_all(
'/([\s.=>(\\\\]_x|^_x)\(\s*' . // _x( or $this->_x(
'([\'"])(.+?)(?<!\\\\)\\2\s*,\s*' . // "text", '([\'"])(.+?)(?<!\\\\)\\2\s*,\s*' . // "text",
'([\'"])(.+?)(?<!\\\\)\\4\s*' . // "context" '([\'"])(.+?)(?<!\\\\)\\4\s*' . // "context"
'[^)]*\)+(.*)$/m', // , textdomain (optional) and everything else '[^)]*\)+(.*)$/m', // , textdomain (optional) and everything else
$data, $matches[3]); $data, $matches[3]
);
// Find _n('singular text', 'plural text', $cnt, textdomain) or $this->_n(...) style matches // Find _n('singular text', 'plural text', $cnt, textdomain) or $this->_n(...) style matches
preg_match_all( '/([\s.=>(]_n|^_n)\(\s*' . // _n( or $this->_n( preg_match_all(
'/([\s.=>(\\\\]_n|^_n)\(\s*' . // _n( or $this->_n(
'([\'"])(.+?)(?<!\\\\)\\2\s*,\s*' . // "singular", '([\'"])(.+?)(?<!\\\\)\\2\s*,\s*' . // "singular",
'([\'"])(.+?)(?<!\\\\)\\4\s*,\s*' . // "plural", '([\'"])(.+?)(?<!\\\\)\\4\s*,\s*' . // "plural",
'.+?\)+(.*)$/m', // $count, optional textdomain, closing function parenthesis ) and rest of line '.+?\)+(.*)$/m', // $count, optional textdomain, closing function parenthesis ) and rest of line
$data, $matches[4]); $data, $matches[4]
);
return $matches; return $matches;
} }