如何使 PoEdit 正确解析自定义“ngettext”执行?

发布于 2024-09-12 18:00:11 字数 834 浏览 4 评论 0原文

我编写了一个 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 只有 _gettextgettext_noop 作为默认的按键,没有任何参考ngettextdngettextdcngettext 函数,但它仍然可以正确接收 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尬尬 2024-09-19 18:00:11

我找到了解决方案,必须使用以下表达式定义关键字:

_e:1,2

来源: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:

_e:1,2

Source: http://osdir.com/ml/editors.poedit.user/2008-05/msg00012.html

情深缘浅 2024-09-19 18:00:11

实际上你需要做上面两件事。

  • 定义关键字如 '_e:1,2'
    AND
  • 添加复数形式
    n复数=2;复数=n!= 1;

到目录设置

Actually you need to do both things above.

  • Define the keyword like '_e:1,2'
    AND
  • Add the plural form
    nplurals=2; plural=n != 1;

to the catalogue settings

影子的影子 2024-09-19 18:00:11

这是另一种解决方案,设置非常容易。只需按照以下步骤操作:

菜单:目录 ->设置将打开“设置”对话框。在“项目信息”选项卡上,您将在底部找到“复数形式”。只需复制&将以下行粘贴到该字段中:

nplurals=2; plural=n != 1;

这将完美解决问题。我什至不需要重新扫描来源;正确的行会自动出现在 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:

nplurals=2; plural=n != 1;

That will fix the problem perfectly. I didn't even had to rescan the sources; the correct lines automatically appeared in the PoEditer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文