message-format-wg icon indicating copy to clipboard operation
message-format-wg copied to clipboard

Allow constraints on arguments

Open macchiati opened this issue 1 year ago • 3 comments

Translation pipeline software need to be able to expand (or contract) the possible options for plural and ordinal rules based on the locale. The worst case expansion of plurals is pretty bad: with some locales for two plural selectors, 36 variant messages may be needed.

The number of expansions can be significantly reduced if the translation software can be informed as to constraints on the input arguments.

Examples: There are locales where:

  • the 'other' category cannot be triggered if the argument can only be an integer.
  • the 'zero' category cannot be triggered if the argument ≥ 1.
  • the 'one' category wouldn't be triggered if there is a literal 1.

Cf. https://cldr-smoke.unicode.org/staging-dev/charts/43/supplemental/language_plural_rules.html

If we had some kind of syntax in MF whereby the developer can communicate this kind of information to the translation software, it would help to reduce translation costs.

Given the schedule, this might not be a feature for MF2.0, but should be kept in the queue. Here is a straw-man proposal (not that I'd necessarily recommend this particular syntax):

limit $peopleInGroup {> 1, integral}

match {$peopleInGroup :number} when other {There are $peopleInGroup people in the group, including you.}

// It wouldn't need the 'one' case in English, or in other locales where it only triggers on integers ≤ 1

macchiati avatar Apr 10 '23 20:04 macchiati