在一个文件夹中,我需要递归更改所有函数调用,例如
$this->ts("couldbeanystring")
/* should now be: */
$this->translate("couldbeanystring", [], "admin")
在每个.php文件中。我可以从bash,phpstorm,以任何方式做到这一点。谢谢!
使用 sed 的简单解决方案:
sed -e 's/$this->ts(("[^"]*")/$this->translate(1, [], "admin")/'
它为ts创建单个捕获组,无论参数如何,并从\1构建新调用