label_EditorTranslator1 test maybe differs from spec

link to test

The specification for term fallback says

“verb” and “short” both fall back to “long”

It doesn’t indicate how plurality factors in but it seems more correct, grammatically, if

  • plural-short falls back to plural-long (e.g. “pages” used if “pp.” not provided),
  • not plural-short falling back to singular-short (e.g. “p.” used if “pp.” not provided).

But this test does the latter. It has

<label variable="number-of-pages" form="short" prefix="&#xA0;" suffix="”/>

which, because no plural abbreviation is provided in the locale, it resolves as

100 p.

However, the locale does have the long plural so I was rendering this as

100 pages.

Is the test correct?

For now I’ve updated my term fallback logic as follows

while value == nil {
    switch tryForm {
        case .shortVerb: tryForm = .verb
        case .symbol: tryForm = .short
        case .verb: tryForm = .long
        case .short:
            if adjustedPlural {
                // first fall-back to non-plural
                // seems grammatically wrong but required by label_EditorTranslator1.txt
                adjustedPlural = false
            } else {
                // revert plural then try other form
                adjustedPlural = plural
                tryForm = .long
        default: return "" // nothing left to try
    value = tryValue(form: tryForm, plural: adjustedPlural)

Yes, the test is correct – as you note, it’s not properly covered in the specs, but given how styles & locales work, it makes pragmatic sense to prioritize form=“short” over singular/plural context.

1 Like