poedit动态gettext的解决方法 [英] poedit workaround for dynamic gettext

查看:34
本文介绍了poedit动态gettext的解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用 gettext 来翻译我发送给用户的文本和消息.我正在使用 poedit 作为编辑器,但我正在努力处理动态消息.

I have started using gettext for translating text and messages i send to user. I am using poedit as an editor, but i am struggling with dynamic messages.

例如,我有类似登录之类的东西,其中有一个变量告诉错误类型.

For example i have things like the login where i have a variable that tells the type of error.

$this->translate('page-error-' . $error);

当我从 poedit 自动更新时,它会读取为page-error-".我所做的是有一个文件,我在其中对 translate 方法进行虚拟调用,其中包含所有可能的键,以便在自动更新时将它们添加到我的 poedit 中.

When i auto update from poedit this gets read like "page-error-". What i do is have a file where i place dummy calls to the translate method with all the possible keys to have them added in my poedit when auto updating.

我不是特别喜欢这种情况.你们是怎么做到的.

I don't particularly like this situation. How do you guys do it.

感谢您的想法

推荐答案

不——这是不可能的,因为编辑器(和 gettext 工具)正在读取您的源代码,而不是执行您的程序.您必须自己保留虚拟调用或将密钥添加到翻译文件中.

No -- this is not possible, because the editor (and the gettext tools) are reading your sources, not executing your program. You'll have to keep the dummy calls or add the keys to the translation files yourself.

这篇关于poedit动态gettext的解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆