1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-17 12:10:45 +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]); 2 => array(), // __('text', [textdomain]);
3 => array(), // _x('text', 'context', [textdomain]) or $this->_x('text', 'context'); 3 => array(), // _x('text', 'context', [textdomain]) or $this->_x('text', 'context');
4 => array(), // _n('singular', 'plural', $cnt, [textdomain]) or $this->_n(...); 4 => array(), // _n('singular', 'plural', $cnt, [textdomain]) or $this->_n(...);
); );
if(!is_file($file)) return $matches; if(!is_file($file)) return $matches;
@@ -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(
'([\'"])(.+?)(?<!\\\\)\\2' . // "text" '/(>_)\(\s*' . // $this->_(
'\s*\)+(.*)$/m', // and everything else '([\'"])(.+?)(?<!\\\\)\\2' . // "text"
$data, $matches[1]); '\s*\)+(.*)$/m', // and everything else
$data, $matches[1]
);
// Find __('text', textdomain) style matches // Find __('text', textdomain) style matches
preg_match_all( '/([\s.=(]__|^__)\(\s*' . // __( preg_match_all(
'([\'"])(.+?)(?<!\\\\)\\2\s*' . // "text" '/([\s.=(\\\\]__|^__)\(\s*' . // __(
'(?:,\s*[^)]+)?\)+(.*)$/m', // , textdomain (optional) and everything else '([\'"])(.+?)(?<!\\\\)\\2\s*' . // "text"
$data, $matches[2]); '(?:,\s*[^)]+)?\)+(.*)$/m', // , textdomain (optional) and everything else
$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(
'([\'"])(.+?)(?<!\\\\)\\2\s*,\s*' . // "text", '/([\s.=>(\\\\]_x|^_x)\(\s*' . // _x( or $this->_x(
'([\'"])(.+?)(?<!\\\\)\\4\s*' . // "context" '([\'"])(.+?)(?<!\\\\)\\2\s*,\s*' . // "text",
'[^)]*\)+(.*)$/m', // , textdomain (optional) and everything else '([\'"])(.+?)(?<!\\\\)\\4\s*' . // "context"
$data, $matches[3]); '[^)]*\)+(.*)$/m', // , textdomain (optional) and everything else
$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(
'([\'"])(.+?)(?<!\\\\)\\2\s*,\s*' . // "singular", '/([\s.=>(\\\\]_n|^_n)\(\s*' . // _n( or $this->_n(
'([\'"])(.+?)(?<!\\\\)\\4\s*,\s*' . // "plural", '([\'"])(.+?)(?<!\\\\)\\2\s*,\s*' . // "singular",
'.+?\)+(.*)$/m', // $count, optional textdomain, closing function parenthesis ) and rest of line '([\'"])(.+?)(?<!\\\\)\\4\s*,\s*' . // "plural",
$data, $matches[4]); '.+?\)+(.*)$/m', // $count, optional textdomain, closing function parenthesis ) and rest of line
$data, $matches[4]
);
return $matches; return $matches;
} }