sprintf function problems with pluralrule

Bug #996987 reported by Gregor Anželj
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Richard Mansfield

Bug Description

sprintf function, used by smarty has problems with pluralrule which contains percent (%) sign.

I've used quite some time to find out that I need to use double percent sign to make this work.

If pluralrule string is translated via launchpad Mahara Translations, than there should be note, warning people of that, but if it is created programmatically than single percent signs in pluralrule string should be replaced with dobule percent signs.

This musn't be confused with the string that appears in plural function though!!!

'Original' string (for Slovenian) as it appears in Launchpad Slovenian Language Details page (https://translations.launchpad.net/mahara-lang/trunk/+pots/mahara/sl/+details)
$string['pluralrule'] = '(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0)';

'Corrected' string (single % replaced with double %% - which sprintf can "digest")
$string['pluralrule'] = '(n%%100==1 ? 1 : n%%100==2 ? 2 : n%%100==3 || n%%100==4 ? 3 : 0)';

AFAIK the affected languages could be:
- Arabic
- Croatian
- Romanian
- Russian
- Slovenian

Revision history for this message
Gregor Anželj (gregor-anzelj) wrote :
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Thanks for tracking this down Gregor, I need to fix it in the scripts which create the language pack tarballs from the launchpad po files. Once it's done, people will need to download fixed language packs and reinstall them :(

Changed in mahara:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Richard Mansfield (richard-mansfield)
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

It turns out this is best fixed in Mahara, leaving the language packs as they are.

See https://reviews.mahara.org/1204

If the % are simply replaced by %% in the language packs, then plural strings do not work properly when formatted in javascript. For example, if you attach a file to a blog post, and then go to the files area and try to delete that file, you get "This file is attached to 1 other item in your portfolio." / "Ta datoteka je pripeta k 1 drugima elementoma v vašem listovniku."

Changed in mahara:
milestone: none → 1.5.2
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/1204
Committed: http://gitorious.org/mahara/mahara/commit/21e485836870940a9b0435038995c6caec862401
Submitter: Hugh Davenport (<email address hidden>)
Branch: 1.5_STABLE

commit 21e485836870940a9b0435038995c6caec862401
Author: Richard Mansfield <email address hidden>
Date: Thu May 10 11:04:39 2012 +1200

    Don't run pluralrule string through sprintf (bug #996987)

    The pluralrule string is used to generate plural forms in javascript,
    so % signs should not be replaced. Using get_raw_string rather than
    get_string reads the string as-is, without running it through sprintf.

    Change-Id: I709b8ef623cdc4df24828866dc62dd229107ef60
    Signed-off-by: Richard Mansfield <email address hidden>

Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/1205
Committed: http://gitorious.org/mahara/mahara/commit/970186cb0f5e5ea5af03be528039a95ba1a837de
Submitter: Hugh Davenport (<email address hidden>)
Branch: master

commit 970186cb0f5e5ea5af03be528039a95ba1a837de
Author: Richard Mansfield <email address hidden>
Date: Thu May 10 11:04:39 2012 +1200

    Don't run pluralrule string through sprintf (bug #996987)

    The pluralrule string is used to generate plural forms in javascript,
    so % signs should not be replaced. Using get_raw_string rather than
    get_string reads the string as-is, without running it through sprintf.

    Change-Id: I709b8ef623cdc4df24828866dc62dd229107ef60
    Signed-off-by: Richard Mansfield <email address hidden>

Melissa Draper (melissa)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.