[ckan-dev] Question about singular/plural translation

Stefan Oderbolz stefan.oderbolz at liip.ch
Fri Jan 15 08:45:43 UTC 2016


Hi there,

I have a question remotely related to CKAN. I currently work on a
multilingual CKAN portal. Therefore there are a lot of "static" string that
are being translated using the gettext functionality:

Then we extract all these messages, translate it and generate the .po and
.mo files (basically following this guide:
https://github.com/ckan/ckan/wiki/Translations-and-Extensions).

Now I noticed something strange: If you have the same string in a
pluralized form and without, the translation will not be found.

e.g. in one template you use this:
{{ ungettext('Organization', 'Organizations', org_count) }}

and in another you use this:
{{ _('Organization') }}

The resulting catalog may look like this:

msgid "Organization"
msgid_plural "Organizations"
msgstr[0] "Organisation"
msgstr[1] "Organisationen"


The ungettext version works as expected, as it is looking for either the
singular or plural form. But the "normal" _() function fails to find the
translation and returns out the original value, instead of falling back to
the singular form. Is this a bug of the gettext implementation? Or should
these cases be extracted differently? Which makes it bug in the extractor?

Of course I could solve this by using ungettext on both places, but for
that I need to recognize these cases. I couldn't find anything about this
behaviour.

Any hint is very appreciated!

- Stefan

-- 
Liip AG  // Limmatstrasse 183 //  CH-8005 Zürich
Tel +41 43 500 39 80 // GnuPG 0x7B588C67 // www.liip.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20160115/91299dad/attachment-0002.html>


More information about the ckan-dev mailing list