gmarty / xgettext

Extracts translatable strings from source. Identical to xgettext but for template languages.
MIT License
77 stars 35 forks source link

using {{n_ "text" "texts" count}} doesn't extract the data #53

Closed tombertrand closed 8 years ago

tombertrand commented 8 years ago

Hey, I've been doing experiments and trying the plural form of words. I'm having difficulties to extract text using the n_ shorthand suggested in the gettext-handlebars while ngettext works as expected.

Result from ngettext screen shot 2016-07-13 at 10 59 32 am

On a side note, would it be possible to run the xgettext-template cmd using different helpers name? for example, I would like to use {{l10n "text"}} instead of {{_ "text"}}?

Thanks.

smhg commented 8 years ago

Your last question first: yes, you can specify your own keywords with the --keyword parameter.

Could you paste an example file for which plural forms are not being extracted?

tombertrand commented 8 years ago

I'm having this in a .hbs template, (not both lines at once, I'm replacing for testing)

<h2>{{ngettext "Payment" "Payments" 3}}</h2> <!-- works -->
<h2>{{n_ "Payment" "Payments" 3}}</h2> <!-- no output for "payment" to be found inside the po file -->
smhg commented 8 years ago

If you run xgettext-template --help you see the default plural keyword is only ngettext. You'll need to specify your own for this to work.

These options should do it: -k gettext -k _ -k ngettext:1,2 -k n_:1,2

tombertrand commented 8 years ago

oh! thank you for the very quick reply

tombertrand commented 8 years ago

works like a charm