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

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

问题描述

我已经开始使用gettext来翻译我发送给用户的文本和消息. 我使用poedit作为编辑器,但是我在动态消息方面苦苦挣扎.

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

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

当我从poedit中自动更新时,它的读取内容类似于"page-error-". 我要做的是创建一个文件,在该文件中,我使用所有可能的键将对虚拟方法的伪调用放置到translate方法上,以便在自动更新时将它们添加到我的poedit中.

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

感谢您的想法

解决方案

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

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);

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.

Thanks for your ideas

解决方案

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.

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

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