Add PluralRules.getSingleValue(keyword)

Description

Deleted Component: formatting

When plural messages are being translated, we have to know whether or not it is safe for the # (the number placeholder) to be omitted for a given keyword. For example, the following are safe:

English - ONE: You have a friend
Arabic - TWO: You have a couple of friends

And the following would not be safe to remove the #:

Croatian - ONE: You have # friends // # might be 1, but might also be 51, etc.
Slovenian - TWO: You have # friends // # might be 2, but might also be 102, etc.

This is not trivial to do externally; say we had the following rule. We'd have to query all the way to 1000000 to find this out. And rules for some languages can be this strange.

  • n is 1 or n mod 1000000 is 1

So what I propose that we do is that:

  • when the rules are created, as we parse parsing we set a flag if the rule is of the form "n is X".

  • we notify rule providers in the API, etc. that they must use this format whenever it is true, that is, not have degenerate cases like n in 2..4 and n not in 3..4.

I suggest that the result of this function have the following values:

  • NaN - the keyword is not an element of getKeywords() or has multiple values

  • X - singlevalued - there is exactly one numeric value for this keyword, and X is it.

Activity

Show:
TracBot
June 30, 2018, 11:33 PM
Trac Comment 2 by —2011-02-16T19:29:21.544Z

I'd like to call this API 'getUniqueKeywordValue' instead, since this is more descriptive.

TracBot
June 30, 2018, 11:33 PM
Trac Comment 3 by —2011-02-16T19:44:00.969Z

I'd like to call this API 'getUniqueKeywordValue' instead, since this is more descriptive.

TracBot
June 30, 2018, 11:33 PM
Trac Comment 5 by —2011-03-02T19:31:17.138Z

`getUniqueKeywordValue()` should be synchronized, right?
Otherwise LGTM.

TracBot
June 30, 2018, 11:34 PM
Trac Comment 7 by —2016-10-05T23:13:36.787Z

Milestone 4.7.1 deleted

Fixed

Assignee

Douglas Felt

Reporter

Mark Davis

Components

None

Labels

None

Reviewer

None

Priority

major

Time Needed

Days

Fix versions