沃梦达 / 编程问答 / php问题 / 正文

如何使 PoEdit 正确解析自定义“gettext"执行?

How to make PoEdit correctly parse custom quot;ngettextquot; implementation?(如何使 PoEdit 正确解析自定义“gettext执行?)

本文介绍了如何使 PoEdit 正确解析自定义“gettext"执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 gettext 包装器,它使 l10n 的整个过程稍微简单一些,但不知何故,我无法让 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);

但这根本不起作用,PoEdit 什么都不选.我也试过了:

But that doesn't work at all, PoEdit picks nothing at all. I also tried:

_e('%d house', '%d houses', 5);

这次 PoEdit 捕捉到 %d house 但不是 %d house 的复数形式,但是如果我尝试完全相同但使用 ngettext() 称它完美运行,单数和复数形式都被识别:

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

我已正确 (?) 将 _e 关键字添加到项目设置中,但它没有选择复数变体.我还注意到 PoEdit 只有 _gettextgettext_noop 作为默认的按键,没有任何参考ngettextdngettextdcngettext 函数,但它仍然可以正确接收 ngettext 调用...这让我想知道 PoEdit 是否对 ngettext 关键字进行了硬编码——那真的很难过.

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.

无论如何,有没有办法让 PoEdit(或任何其他类似的应用程序)正确解析自定义函数?

Anyway, is there any way to make PoEdit (or any other similar app), correctly parse custom functions?

推荐答案

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

I've found the solution, the keyword has to be defined with the following expression:

_e:1,2

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

这篇关于如何使 PoEdit 正确解析自定义“gettext"执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何使 PoEdit 正确解析自定义“gettext"执行?

基础教程推荐