Yeah, somebody's gotten a little bit excited there with
search-and-replace at some point. It should be ngettext(), not
ungettext().
Regards,
Malcolm
--
If you think nobody cares, try missing a couple of payments.
http://www.pointy-stick.com/blog/
Depends on whether you'd like them to be fixed or not. :-)
Malcolm
--
Tolkien is hobbit-forming.
http://www.pointy-stick.com/blog/
I can't test this now but it seems you are mixing things
if you are going to do a named interpolation you should
use an array (or other JS data structure) that contains an element
named after the value you are using inside the literal
a = Array('count');
a('count') = 7;
a('name') = 'Dood';
interpolate(
ngettext('%(name)s: You have 1 contact.',
'You have %(count)s contacts. Go %(name)s!', a.count),
a)
You are using '%(count)s' but are passing [contact_count] as the 'named'
parameter to interpolate(), a totally unrelated name so there is no
interpolation possible.
Or if you don't need named interpolation at all (as your bare
contact_count variable seems
to indicate) just don't:
contact_count = 7;
ngettext('You have 1 contact.', 'You have %s contacts.', contact_count);
PS: Are you going to open the ticket with the two JS i18n doc fixes? I have a
mini-patch ready to submit.
Regards,
--
Ramiro Morales
On Sat, Mar 22, 2008 at 10:08 AM, Julien <jph...@gmail.com> wrote:
>
> Hi there,
>
> I debugged the generated javascript catalog and functions, and in
> ngettext, the variable "value" is correct (an array with 2 cells: the
> translated singular and plural), but the statement "return
> value[pluralidx(count)]" returns null, simply because pluralidx itself
> returns True of False.
>
> Wouldn't the following be a more correct implementation of ngettext?
>
>
> function ngettext(singular, plural, count) {
> value = catalog[singular];
> if (typeof(value) == 'undefined') {
> return (count == 1) ? singular : plural;
> } else {
> return value[(pluralidx(count))?1:0];
> }
> }
>
> What do you think?
>
This may be caused by the djangojs.po catalog of your
application/project missing
the Plural-Foms header, for example (for the the Argentinia spanish
django.po) it is:
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
In fact now I see neither the django.po or the djangojs.po files of the Django
french traslation have that header.
(oops the djangojs.po for es_AR is also missing it :-))
I don't know if and which plural form formula does the french language use.
If so,and you happen to know or obtain it, try adding it to your
app/project .po files.
If the javascript_catalog() view doesn't detect a plural forms line in
your catalog
(line 156 of django/views/i18n.py) it uses a very basic one (the one
you are seeeing).
There is a [1]ticket opened a while ago about making the Django catalog handling
scripts copy the plural forms formula header from the Django .po files
to the app/project one when creating them.
Regards,
--
Ramiro Morales
PS: Just opened ticket #6859 with a patch for the doc innacuracies you
reported. Thanks.
On Sat, Mar 22, 2008 at 9:00 PM, Julien <jph...@gmail.com> wrote:
>
> Hi,
>
> In fact, I'm using my own po file, and the plural rule is exactly the
> same one as you've mentioned above. So, I've changed the rule to:
> "Plural-Forms: nplurals=2; plural=(n > 1)?1:0;\n"
Glad to see it' working for you now. Sorry for trying to help
without grasping all the details.
I've tried to solve it in a similar way but at a different point to be safe in
the case an author of a (Django or app) djangojs.po catalog specifies
Plural-Forms: nplurals=2; plural=n>1;
instead of
Plural-Forms: nplurals=2; plural=n>1 ? 1 : 0;
because the first form (the one that relies on the "feature of C
expressions that boolean
expressions have to value zero or one.") is shown in the [1]official GNU gettext
documentation.
I've opened ticket #6864 with a patch attached. could you give it a try?.
>
> Also, I've spotted another glitch in the doc, which I've reported in
> the ticket you've opened: http://code.djangoproject.com/ticket/6859
>
I've updated the patch, do you think it's Ok?, thanks!.
Regards,
--
Ramiro Morales
1. http://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html#Plural-forms