Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPlural with strings defined elsewhere #332

Open
cmalard opened this issue Feb 28, 2017 · 1 comment
Open

getPlural with strings defined elsewhere #332

cmalard opened this issue Feb 28, 2017 · 1 comment

Comments

@cmalard
Copy link

cmalard commented Feb 28, 2017

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)

@cmalard
Copy link
Author

cmalard commented Mar 4, 2017

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant