0

It seems like using pluralization in ICU message format is not dependable when combined with static text.

Take the following example:

Please see the {itemCount, plural,
  one {message}
  other {messages}
} in your inbox.

In Spanish, the word "the" changes depending on whether or not it's plural. The correct translations in Spanish should be:

one: "Por favor vea el mensaje en su bandeja de entrada"
other: "Por favor vea los mensajes en su bandeja de entrada"

The way to solve this would be to include "the" in the conditional.

Developers are obviously not going to be fluent in every language their app supports. If you don't speak Spanish, you wouldn't know to include "the" in the conditional.

It seems irresponsible to allow this type of syntax. Format.js even promotes using pluralization like this in their examples: https://formatjs.io/docs/core-concepts/icu-syntax/#plural-format

It seems to me that an error should be thrown when attempting to combine static text with dynamic plural text. The entire sentence should be required in the conditional.

My question is: Am I missing something? Should I prohibit my developers from entering values like this?

I can't be the first person that noticed this. Is there a way to enforce this through a setting in Format.js?

dcporter7
  • 535
  • 3
  • 14

1 Answers1

0

Looking at the documentation it looks as though your confusing the {selectordinal} with the message.

By way of an example the Spanish format based on what you have provided would be:

Por favor vea {itemCount, plural,
  one {el mensaje}
  other {los mensajes}
} en su bandeja de entrada.

Even so that is a relatively simple example as you may also have additional words later in the sentence affected by ordinal number, gender, or both so you may have to have multiple arguments in the sentence.

Declension is quite the fun linguistic topic for developers to get their heads around.

Edit: To add to this, that would give you something like:

const messages = {
  en: {
    INBOX: 'Please see the {itemCount, plural, 
        one {message}
        other {messages}
     } in your inbox.',
  },
  es: {
    INBOX: 'Por favor vea {itemCount, plural,
         one {el mensaje}
         other {los mensajes}
     } en su bandeja de entrada.',
  },
}

So for the Spanish it is necessary to move the 'the' into the argument, but not for the English. It is really down to the syntax and the person creating localised messages to utilise that syntax for whatever gendered or ordinal conditions they need to be aware of.

Mark
  • 880
  • 8
  • 18
  • Thanks. I didn't really think about how the Spanish translator could decide to put "el" and "los" into the argument while the English does not. It does require that the translator have a more full understanding of the syntax, but this is a lot more possible than having devs have a full understanding of Spanish. But like you said, this is a simple example. There are definitely more complicated examples where my point still stands. And due to those complicated cases, I still don't think I'd want my devs doing this. – dcporter7 Jan 06 '23 at 16:28
  • 1
    To make life easier for translators (which usually means better quality) you can include the full messages in the plural dependent section: ``` {itemCount, plural, one {Please see the message in your inbox.} other {Please see the messages in your inbox.}} ``` Usually the second message is not going to cost you full price, there is a discount for "fuzzy match" (might need to discuss this with the translators / translation company) – Mihai Nita Jan 24 '23 at 10:14
  • @MihaiNita I agree. I think using the full message in the plural contexts is the only real solution. And it should be the only way it's done. Only time it isn't necessary is when the developers are multilingual in every language their app uses. Which is to say almost never. – dcporter7 Jan 27 '23 at 23:06