简体   繁体   English

使用poEdit在以Jed本地化的JS源文件中查找gettext字符串

[英]Using poEdit to find gettext strings in a JS source file localized with Jed

I need to localize a Javascript source file, and after looking for a bit, I decided to use Jed (side question: you can use it without having to use node.js, right? It wasn't clear to me reading the docs). 我需要本地化Javascript源文件,经过一番寻找之后,我决定使用Jed (附带的问题:您可以使用它而不必使用node.js,对吗?我不清楚阅读文档的情况) 。 I went through my JS files and changed all the strings that needed localizing from: 我浏览了JS文件,并从以下位置更改了所有需要本地化的字符串:

 var title = "Bla bla bla";

To: 至:

var title = i18n.translate("Bla bla bla").fetch();

Then I opened poEdit (version 1.7.4), created a new catalog, and in the keywords section, added: 然后,我打开poEdit(版本1.7.4),创建了一个新目录,并在关键字部分中添加了:

translate(
i18n.translate

I then ran "Update from sources"... and poEdit doesn't find anything. 然后,我运行“从源代码更新” ...,而poEdit找不到任何东西。

What am I doing wrong? 我究竟做错了什么?

Add just translate to the keywords, it works fine. 只需translate添加到关键字即可,效果很好。

There's no reason to add ( to it ( translate( is not a valid JavaScript function name!) and there's even less reason to do it inconsistently for only some of the keywords, but not others. Finally, xgettext 's parser won't recognize i18n. namespacing, so adding that has no effect. 没有理由添加(translate(不是有效的JavaScript函数名称!)),甚至没有理由只对某些关键字而不是其他关键字进行不一致的修改。最后, xgettext的解析器将无法识别i18n. ,因此添加该名称无效。

You may want to reconsider the use of Jed, though, unless you have very simple needs. 但是,除非有非常简单的需求,否则您可能要重新考虑使用Jed。 Looking at the crazy (in Jed terminology: “sane”) API, there's no way xgettext could parse its way of doing contexts and plurals. 看着疯狂的(用Jed术语来说:“理智的”)API, xgettext无法解析其处理上下文和复数的方式。 There's no custom tool included with Jed to deal with it, so it seems you'd be reduced to create PO(T)s manually if you wanted contexts/plurals — something that goes against the entire concept of gettext. Jed没有包含自定义工具来处理它,因此,如果您需要上下文/复数,似乎可以减少手动创建PO(T)的工作–这与gettext的整个概念背道而驰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM