[ckan-dev] Question about singular/plural translation

Adrià Mercader adria.mercader at okfn.org
Fri Jan 15 10:42:34 UTC 2016


Hi Stefan,

First of all I don't know if you are aware that starting on CKAN 2.5
there's a much more convenient way to handle translations from
extensions using some interfaace and default locations for folders:

http://docs.ckan.org/en/latest/extensions/translating-extensions.html

ckanext-harvest and others use it already:

https://github.com/ckan/ckanext-harvest/tree/master/ckanext/harvest/i18n

I'll mark the wiki page you mention as deprecated.

As for your particular issue, I'm not sure what's going on. On the
resulting catalog, do you have two separate entries, one for the
singular and one for the plural variant? eg

msgid "Organization"
msgstr "Organisation"

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



Adrià


On 15 January 2016 at 08:45, Stefan Oderbolz <stefan.oderbolz at liip.ch> wrote:
> 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
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>



More information about the ckan-dev mailing list