我正在检查 language.ini 中翻译字符串的使用情况。项目中的开发人员使用''
,但甚至可能使用,""
因为 PHP 允许两者(即使它们之间存在很大差异)。
还有变量的用法;
$thisText = !true ? 'Xyz' : 'Abcd';
$this->translate($thisText);
问题是正确包装包含单引号或双引号的表达式 - 类似 ["']translation string["']
有没有办法用 grep 检查文件是否在 Bash 命令行中出现类似的情况?
例子
file a.php, b.php, c.phtml, d.js
a.php:
$transString = rand(0,42) == 42 ? 'Search results' : 'Nothing found';
$this->translate($transString);
b.php:
//translate 'Location'
return $this->translate("Location");
c.phtml:
<?= $this->translate('Location'); ?>
d:
trans.translate('current_location');
想要匹配translate("Location")
或translate('Location');
和'Location'
如果我寻找例如。"42"
它应该寻找"42"
'42'
我只是忘了逃跑 "[\"']"
egrep -r --include=\*.{php,phtml,js} --exclude-dir={languages} "[\"']${term}[\"']" ./
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句