Difference between revisions of "Language Packs/Plural forms"
(Created page with "== Translation of plural forms == Mahara now has support for translations of languages with different plural forms. However, very few of the strings in the English language pac…")
Latest revision as of 11:17, 25 June 2012
Translation of plural forms
Mahara now has support for translations of languages with different plural forms. However, very few of the strings in the English language pack have been converted to use the correct format, so there are still many strings that are either not pluralised at all (e.g. "deleted 5 file(s)", "deleted 1 files"), or which are hardcoded to have only the two plural forms in English (i.e. there are two separate strings, one for "deleted %s files", and another for "deleted one file").
Format for new strings
All new English strings added to Mahara should be added in such a way as to allow correct translation of plurals. For example, if you are adding a string for "you have updated n files", you would put something like this in the language string file:
$string['updatednfiles'] = array( 0 => 'You have updated %s file.', 1 => 'You have updated %s files.', );
And you would put something like this in the code:
$message = get_string('updatednfiles', 'artefact.file', $numberofupdatedfiles);
Either the string for plural form 0 or plural form 1 will be used, depending on the value of $numberofupdatedfiles.
Translation of pluralised strings
If the string is already properly pluralised in English, translation is straightforward. Launchpad's translation interface, and the (and poedit, etc. tools) make it obvious.
If you are not using launchpad or the po format, you add plurals to the Mahara language pack in the following format:
$string['fileattachedtoportfolioitems'] = array( 0 => 'Ta datoteka je pripeta k %s drugemu elementu v vašem listovniku.', 1 => 'Ta datoteka je pripeta k %s drugima elementoma v vašem listovniku.', 2 => 'Ta datoteka je pripeta k %s drugim elementom v vašem listovniku.', 3 => 'Ta datoteka je pripeta k %s drugim elementom v vašem listovniku.', );
Pluralising existing English strings
If a string is not properly pluralised in English, it cannot be translated correctly in some languages until the English language pack has been fixed. The following commit shows a few examples of how to fix up an existing string: https://gitorious.org/mahara/mahara/commit/526e469835876d958e1f1f1dcf5dad680168ffec
A new name for the string should be used when a string is pluralised. This will force translators to re-translate the string. The old unpluralised string should only be deleted when you are sure there no uses of it remain in core code.
Patches to fix existing strings should go only to the master branch, and should be submitted to the code review system in the same way as any other change to the Mahara code: they should be small, self-contained, easy to review, and in general follow the guidelines on the Contributing Code page.