我正在开发一个提供与 poEdit 相同功能的 Web 界面。
我想遍历指定文件夹中的所有 .php 文件并搜索每一行以进行翻译。为此,我想使用正则表达式搜索 php 文件中的实际行并返回翻译文本参数和域参数。
我的功能如下所示:
__('This is my translation', 'domain');
但是因为我为域参数定义了一个默认值,所以函数 __() 也可以这样调用:
__('this is my translation');
现在在 PHP 中,我尝试使用函数 preg_match_all() 但我不能将我的正则表达式放在一起。
这是脚本中可能行的示例以及我希望使用 preg_match_all() 函数接收的输出数组:
echo __('Hello World'); echo __('Some domain specific translation', 'mydomain');
数组输出:
Array
(
[0] => Array
(
[0] => Hello World
)
[1] => Array
(
[0] => Some domain specific translation.
[1] => mydomain
)
)
谁能帮我解决正则表达式和 preg_math_all() 标志?
谢谢你们。