angular-gettext
angular-gettext copied to clipboard
getPlural with strings defined elsewhere
Hi @rubenv ,
I would like to declare singular and plural strings outside gettextCatalog.getPlural. Case :
// js file where gettext cannot be injected
const objects = [
{ key: OBJECT1, singular: '', plural: '', ... },
{ key: OBJECT2, singular: '', plural: '', ... },
]
// usage :
gettextCatalog.getPlural(n, object.singular, object.plural);
If I declare a gettext() function to tag the strings, getPlural never links with the plural string because the strings needs to be linked together as :
msgid "singular"
msgid_plural "plural"
msgstr[0] "..."
msgstr[1] "..."
How can I do that without getPlural ?
(when objects is created the code does not know n)
I found this solution with getPlural... not sure I'll use it:
// js file where gettext cannot be injected
const gettextCatalog = { getPlural(n, singular, plural) {
return { singular, plural };
} };
const objects = [
{
key: OBJECT1,
label: gettextCatalog.getPlural(0, 'singular', 'plural'),
},
]
// usage :
gettextCatalog.getPlural(n, object.label.singular, object.label.plural);