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

View File

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