简体   繁体   中英

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). I went through my JS files and changed all the strings that needed localizing from:

 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:

translate(
i18n.translate

I then ran "Update from sources"... and poEdit doesn't find anything.

What am I doing wrong?

Add just translate to the keywords, it works fine.

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.

You may want to reconsider the use of Jed, though, unless you have very simple needs. Looking at the crazy (in Jed terminology: “sane”) API, there's no way xgettext could parse its way of doing contexts and plurals. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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