Allow correct translation of plurals
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
Medium
|
Richard Mansfield |
Bug Description
With the current language pack format, it's impossible to translate many plurals correctly unless the language uses the same rules as English. We need to let translations specify plurals via a function over the number, as described in http://
The following emails have more detail about how we propose to fix this in Mahara:
-------
Subject: Re: Using PluralForms in Mahara strings + DWOO problem/question
From: "Richard Mansfield"
Date: Tue, September 13, 2011 12:16 pm
To: Gregor Anzelj, Francois Marier
-------
Thanks very much for this Gregor, I've now had time to have a good look
at those links you sent, and done a bit of playing around on Mahara.
I'd like to propose that we change Mahara along the lines of this commit:
https:/
And the following commit shows how the strings would look in the default
langpack:
https:/
It's all pretty much the same as your scheme, but just closer to the
gettext/PO format, using a php array to store the different plural forms
rather than special codes inside the string. So to use your example,
this string:
$string[
{{PLURAL:
would be specified like this in the php langpack:
$string[
'%d sporocilo',
'%d sporocili',
'%d sporocila',
'%d sporocil',
);
and like this in our PO files:
#: lang/en.
msgctxt "lang/en.
msgid "%d message"
msgid_plural "%d messages"
msgstr[0] "%d sporocilo"
msgstr[1] "%d sporocili"
msgstr[2] "%d sporocila"
msgstr[3] "%d sporocil"
Keeping our scheme similar to PO & gettext has the advantage that it'll
make the conversion of langpacks to/from PO a lot easier, and the other
advantage is that we won't need to rely on special characters like { and
| inside the translated strings themselves (these characters could
legitimately appear in strings too, and one day that might require us to
dream up some escaping rules).
The disadvantage I see, compared to your scheme, is that we're removing
the option to put multiple plural forms anywhere inside a string. For
example in the second patch above, I had to split a string up, because
"Created %s folders and %s files" contains two plurals. However, I
don't think PO can deal with that nicely (correct me if I'm wrong on
that). If we're expecting people to translate Mahara using standard PO
editing tools and Launchpad, I don't see that we've got much choice but
to limit ourselves to one plural per string.
What do you guys think?
On 29/08/11 19:49, Gregor Anzelj wrote:
> > Regarding plural forms and gettext/ .po files...
> >
> > I think these pages contain all the info needed:
> >
> > * http://
> > *
http://
> >
> > But I think we need to be careful to cover all possible cases:
> >
> > * simple one, e.g.: $string[
> > "{{PLURAL:
> > * not so simple one, e.g.: $string[
> > {{PLURAL:
> >
> > or in Slovenian:
> >
> > * simple one, e.g.: $string[
> > "{{PLURAL:
> > * not so simple one, e.g.: $string[
> > {{PLURAL:
> >
> > HTH,
> > Gregor
> > --
> > ----------
> > Gregor Anzelj, prof.
> > Gimnazija Ledina, Ljubljana
tags: | added: translations |
Changed in mahara: | |
status: | In Progress → Fix Committed |
Changed in mahara: | |
status: | Fix Committed → Fix Released |
https:/ /reviews. mahara. org/922