mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #07674
[Bug 901051] A change has been merged
Reviewed: https://reviews.mahara.org/922
Committed: http://gitorious.org/mahara/mahara/commit/52a6e7e19632665fe037b0a44134045773e5bb78
Submitter: Richard Mansfield (richardm@xxxxxxxxxx)
Branch: master
commit 52a6e7e19632665fe037b0a44134045773e5bb78
Author: Richard Mansfield <richard.mansfield@xxxxxxxxxxxxxxx>
Date: Tue Sep 13 10:25:57 2011 +1200
Modify get_string to take plural forms (bug #901051)
Allows language packs to specify an array of strings (one for each
plural form in the language) instead of a single string.
The first of the variable (sprintf) arguments is assumed to be the
number we need to check to choose a plural form. This argument is
passed into a language-specific function defined in langconfig.php,
which returns the appropriate plural form based on a formula.
A similar scheme is used for strings formatted by the javascript
get_string function in mahara.js.
See http://www.gnu.org/s/hello/manual/gettext/Plural-forms.html
Change-Id: Ifb58ac4f1e13a54edbc57e5c0a9faaf8454e53a4
Signed-off-by: Richard Mansfield <richard.mansfield@xxxxxxxxxxxxxxx>
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
https://bugs.launchpad.net/bugs/901051
Title:
Allow correct translation of plurals
Status in Mahara ePortfolio:
In Progress
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://www.gnu.org/s/hello/manual/gettext/Plural-forms.html
The following emails have more detail about how we propose to fix this
in Mahara:
---------------------------- Original Message ----------------------------
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://github.com/richardmansfield/richardms-
mahara/commit/157c384b2860553ab78fad88f7a32b30d4af0ec2
And the following commit shows how the strings would look in the default
langpack:
https://github.com/richardmansfield/richardms-
mahara/commit/b0aba7671669ab996008a0c65cc11538dc529bda
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['notsosimpleplural'] = "%d
{{PLURAL:%d|sporocilo|sporocili|sporocila|sporocil}}";
would be specified like this in the php langpack:
$string['notsosimpleplural'] = array(
'%d sporocilo',
'%d sporocili',
'%d sporocila',
'%d sporocil',
);
and like this in our PO files:
#: lang/en.utf8/mahara.php notsosimpleplural
msgctxt "lang/en.utf8/mahara.php notsosimpleplural"
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://www.gnu.org/s/hello/manual/gettext/Plural-forms.html
> > *
http://www.gnu.org/s/hello/manual/gettext/Translating-plural-forms.html#Translating-plural-forms
> >
> > But I think we need to be careful to cover all possible cases:
> >
> > * simple one, e.g.: $string['simpleplural'] =
> > "{{PLURAL:%d|view|views}}"; as well as
> > * not so simple one, e.g.: $string['notsosimpleplural'] = "%d
> > {{PLURAL:%d|message|messages}}";
> >
> > or in Slovenian:
> >
> > * simple one, e.g.: $string['simpleplural'] =
> > "{{PLURAL:%d|pogled|pogleda|pogledi|pogledov}}"; as well as
> > * not so simple one, e.g.: $string['notsosimpleplural'] = "%d
> > {{PLURAL:%d|sporocilo|sporocili|sporocila|sporocil}}";
> >
> > HTH,
> > Gregor
> > --
> > ----------
> > Gregor Anzelj, prof.
> > Gimnazija Ledina, Ljubljana
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/901051/+subscriptions
References