[Koha-bugs] [Bug 21156] Internationalization: plural forms, context, and more for JS files
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Mon Oct 1 09:31:04 CEST 2018
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21156
--- Comment #3 from Julian Maurice <julian.maurice at biblibre.com> ---
(In reply to Katrin Fischer from comment #2)
> 1. Add a translatable string in a JS file. For example, add this:
> alert(__nx("There is one item", "There are {count} items", 3,
> {count: 3}));
>
> It looks like we already have a way of doing this with the format() syntax.
Variable substitution works the same way as format() but allows to give names
to substitutions, to ease the work of translators (ex: "I like {food} and
{drink}" is easier to read and translate than "I like %s and %s")
> How would plural translation work? Can you give examples for context and
> plurals?
For plural translation, gettext will select the correct string based on the
integer parameter (the 3rd for __n and __nx, the 4th for __np and __npx) and
the Plural-Forms header in the PO file
For instance,
var count = <a positive integer>
__n('item', 'items', count)
In English, __n will return 'item' if count == 1, 'items' otherwise
In French, __n will return 'exemplaire' if count == 0 or count == 1,
'exemplaires' otherwise, because Plural-Forms is "nplurals=2; plural=(n > 1);
In Slovenian, __n can return up to 4 different strings, because Slovenian has 4
different "plural forms"
The context is just another string to help disambiguation. Ex:
__p('Bibliographic record', 'item')
This will appear in the po file as
msgctxt "Bibliographic record"
msgid "item"
And you can combine context and plural forms
__np('Bibliographic record', 'item', 'items', count)
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list