[Unicode]   Common Locale Data Repository : Bug Tracking Home | Site Map | Search
 
Modify

CLDR Ticket #6544(closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

Add pluralSamples, more structure.

Reported by: mark Owned by: mark
Component: plurals Data Locale:
Phase: Review: pedberg
Weeks: Data Xpath:
Xref:

Description (last modified by mark) (diff)

1. Markus noted: "Andy and I propose to add samples directly into the rule syntax, since we have sample values anyway when we write and modify the rules."

The reason for this is that the sample generation code is fairly complicated, and it is a waste to duplicate it for every platform.

I agree with the reasoning, and suggest the following format:

<pluralRules locales="he">

<pluralRule count="one">v=0 and i is 1</pluralRule>
<pluralRule count="two">v=0 and i is 2</pluralRule>
<pluralRule count="many">v=0 and i not in 0..10 and i mod 10 is 0</pluralRule>
<pluralSamples count="one">1</pluralSamples>
<pluralSamples count="two">2</pluralSamples>
<pluralSamples count="many">20 30 40</pluralSamples>
<pluralSamples count="other">1.0 1.1 2.0 2.1 10 10.0 10.1 2.1..19.9</pluralSamples>

</pluralRules>

The format would be:

  • sampleList = sample_range (space+ sample_range)*
  • sample_range = sample_value (".." sample_value)?
  • sample_value = digit+ ('.' digit+)

A range must have the same number of decimal digits for the start and end. It is interpreted as the set of all numbers between the start and end (inclusive) with the same number of decimals, including trailing zeros. That is:

1.8..2.3 => 1.8 1.9 2.0 2.1 2.2 2.3

Note that unlike the pluralRule, there is an entry for 'other'.

As a part of this, we would add a test that every plural category has at least one sample, and that all the values do indeed have the category.

2. A second important use of the samples is to know whether a keyword (category) is:

  1. singular (only one item matches)
  2. finite (eg only values equal to 1 or 2 would match)
  3. infinite (eg plurals in English, or ordinal-one in English)

This is used in error checking plural messages from translations, eg. to require that a number be present except in those cases where it is clear from the form of the word, eg 'one' in Arabic does not require any digits, since the form of the work makes it clear what the number is.

This is currently computed as part of the sample code in implementations—it is not trivial to compute—and would also need some markup to handle. To do that, I suggest that we add an attribute:

<pluralRule count="one" matchingInts="single">v=0 and i is 1</pluralRule>

Anything without the attribute is not finite; has an infinite number of possible matches.
Many messages will only be used for integer values, so it is important to separate out those cases.

Attributes:

  • matchingInts
  • matchingFloats

For attribute values, I suggest:

  • single: there is exactly one number that matches (eg 1)
  • finite: there is more than one match, but finite (eg 1 or 2)
  • infinite: (the default)

An invariant is that the matchingFloat value is ≥ the matchingInt value (since all the int values are also floats). An alternative name for matchingFloats would be matchingAny.

Note that for this purpose it is the (visible) value that counts, without trailing decimal zeros.

Attachments

Change History

comment:1 Changed 4 years ago by mark

  • Description modified (diff)

comment:2 Changed 4 years ago by mark

  • Description modified (diff)

comment:3 Changed 4 years ago by mark

  • Description modified (diff)

comment:4 Changed 4 years ago by emmons

  • Status changed from new to assigned
  • Component changed from unknown to data-plurals
  • Priority changed from assess to major
  • Milestone changed from UNSCH to 24rc
  • Owner changed from anybody to mark
  • Type changed from unknown to enhancement

comment:5 Changed 4 years ago by emmons

  • Milestone changed from 24rc to 25dsub

comment:6 Changed 4 years ago by emmons

  • Milestone changed from 25dsub to 24final

comment:7 Changed 4 years ago by mark

  • Review set to pedberg

comment:8 Changed 4 years ago by pedberg

  • Status changed from assigned to closed
  • Resolution set to fixed
View

Add a comment

Modify Ticket

Action
as closed
Next status will be 'new'
Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.