You have done a very powerful tool. Thanks!

At configuration page (admin/settings/userpoints) I see a "Points branding". Here I can translate a word "Points" to whatever I want. But in russian (and ukrainian) language we have 3 plural forms... It's only 2 in english

This is my string for plurals from KBabel:
nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);

I just started translation to russian of all module. You have done a very good feature and I'll use it if it posible. Thanks.
You're doing a very useful modules and clear code.

CommentFileSizeAuthor
#5 userpoints.module.plurals.patch1.51 KBtuffnatty

Comments

vladsavitsky’s picture

Also in russian each word has a many endings...
Is it posible to do a plurals within a PO-file. I have seen this in other modules.
This is very flexible solution. Each language has he's own number of plurals and other rules.
Thanks.

jredding’s picture

Can you provide a listing of the modules that provide this type of functionality. I don't speak Russian so its pretty hard for me to wrap my head around how this is supposed to work.

tuffnatty’s picture

Version: 5.x-2.14 » 5.x-3.5
Status: Active » Needs review

jredding,

Here is the listing you asked for:

http://api.drupal.org/api/function/format_plural/6/references

Here are the docs for the function you need:

http://api.drupal.org/api/function/format_plural/6

Currently (5.x-3.5) it is used incorrectly in userpoints.module. Please notice from the docs:
"Since t() is called by this function, make sure not to pass already-localized strings to it."

I think you should change this:

$show_points = format_plural($points, t('!point', userpoints_translation()), t('!points', userpoints_translation()));
$content = t('You have %p %c', array('%p' => $points, '%c' => $show_points));

to this:

$content = format_plural($points, 'You have 1 !point', 'You have @count !points', userpoints_translation());

And probably something like this in some other places where !points are mentioned.

jredding’s picture

oh so format_plural is all that is needed to handle Russian, cool. From the conversation it sounded as if more was needed. I think this can definitely be worked in give it sometime though unless you can submit a patch. (you've already written the code, a quick patch will get it into the module really quick).

tuffnatty’s picture

StatusFileSize
new1.51 KB

Here is a patch regarding format_plurals() against 5.x-3.5.

kbahey’s picture

Version: 5.x-3.5 » 5.x-3.x-dev
Status: Needs review » Fixed

Thank you. Committed.

Should be in -dev in about 24 hours.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.