Skip to content

getPlural with strings defined elsewhere #332

Open

Description

@cmalard

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)

Activity

  1. cmalard commented on Mar 4, 2017

    @cmalard
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions