自动提取字符串进行定义
我刚刚继承了一个用PHP编写的网站来将其国际化......问题是代码不一致。它有一些函数在 echo 和其他部分中有字符串,在另一个函数中,php 被关闭,html 以正确的方式呈现。
我一直在寻找一种可以尽可能简化我的工作的工具。检索尽可能多的字符串并在另一个文件中定义(通过定义)。
我想用正则表达式函数创建一个脚本来实现这一点,但如果有什么东西......我看了但找不到。也许我使用了错误的术语,因为我不是英语母语。
有谁知道一个好方法来做到这一点?
I just inherited a website written in PHP to internationalize it... The problem is the code is not consistent. It has some functions that have strings inside echo and another pieces and in another functions the php is closed and html is presented the right way.
I was looking for a tool that could easy my job as much as possible. Retrieving as much strings as it could and defining (through defines) in another file.
I though about creating a script with regex functions to achieve this but if there was anything out there... I looked but couldn't find. Maybe I'm using wrong terms as I'm not English native.
Does anyone know a good way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您愿意使用
gettext
进行 I18N,那么您可以使用xgettext
:http://www.gnu.org/s/hello/manual/gettext/xgettext-Initation.html这是一个教程,详细介绍了如何用它在PHP: http://www.phpdig.net/ref/rn26.html
If you are open to using
gettext
for I18N, then you can usexgettext
: http://www.gnu.org/s/hello/manual/gettext/xgettext-Invocation.htmlHere is a tutorial detailing how you can use it in PHP: http://www.phpdig.net/ref/rn26.html