如何使 PoEdit 正确解析自定义“ngettext”执行?
我编写了一个 gettext 包装器,使 l10n 的整个过程变得更简单,但不知何故,我无法让 PoEdit 正确识别和解析对该函数的复数版本调用。这就是我最初的想法:
_e(array('%d house', '%d houses'), 5);
但这根本不起作用,PoEdit 根本没有选择任何东西。我也尝试过:
_e('%d house', '%d houses', 5);
这次 PoEdit 捕获了 %d house
但不是 %d house
的复数形式,但是如果我尝试完全相同但使用 ngettext ()
调用它完美地工作,单数和复数形式都被识别:
ngettext('%d house', '%d house', 5);
我已经正确地(?)将 _e
关键字添加到项目设置中,但它没有拾取复数变体。我还注意到 PoEdit 只有 _
、gettext
和 gettext_noop
作为默认的按键,没有任何参考ngettext
、dngettext
或 dcngettext
函数,但它仍然可以正确接收 ngettext
调用...这让我不知道 PoEdit 是否对 ngettext
关键字进行了硬编码 - 这真的很可悲。
无论如何,有什么方法可以使 PoEdit(或任何其他类似的应用程序)正确解析自定义函数?
I've coded a gettext wrapper that makes the whole process of l10n a little bit simpler but somehow I can't get PoEdit to correctly identify and parse plural version calls to the function. This is what I originally had:
_e(array('%d house', '%d houses'), 5);
But that doesn't work at all, PoEdit picks nothing at all. I also tried:
_e('%d house', '%d houses', 5);
This time PoEdit catches the %d house
but not the plural form of %d houses
, however if I try exactly the same but with a ngettext()
call it works perfectly, both the singular and plural forms are identified:
ngettext('%d house', '%d house', 5);
I've correctly (?) added the _e
keyword to the project settings, but it doesn't pick up plural variations. I've also noticed that PoEdit only has _
, gettext
and gettext_noop
as the default keyworks to pick up, there is no reference whatsoever to the ngettext
, dngettext
or dcngettext
functions but it can still correctly pick up the ngettext
calls... This makes me wonder if PoEdit has hardcoded the ngettext
keyword - that would be really sad.
Anyway, is there any way to make PoEdit (or any other similar app), correctly parse custom functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我找到了解决方案,必须使用以下表达式定义关键字:
来源:http://osdir.com/ml/editors.poedit.user/2008-05/msg00012.html
I've found the solution, the keyword has to be defined with the following expression:
Source: http://osdir.com/ml/editors.poedit.user/2008-05/msg00012.html
实际上你需要做上面两件事。
AND
n复数=2;复数=n!= 1;
到目录设置
Actually you need to do both things above.
AND
nplurals=2; plural=n != 1;
to the catalogue settings
这是另一种解决方案,设置非常容易。只需按照以下步骤操作:
菜单:目录 ->设置将打开“设置”对话框。在“项目信息”选项卡上,您将在底部找到“复数形式”。只需复制&将以下行粘贴到该字段中:
这将完美解决问题。我什至不需要重新扫描来源;正确的行会自动出现在 PoEditer 中。
Here is another solution, it is very easy to setup. Just follow the steps below:
Menu: Catalog -> Settings will open the Settings dialog. On the Project Info tab you will find "Plural Forms" at the bottom. Just copy & paste the following line in this field:
That will fix the problem perfectly. I didn't even had to rescan the sources; the correct lines automatically appeared in the PoEditer.