Skip to content

pluralize schema and implementation missing two, few, many branches (v0_9 spec non-conformance) #903

@BBC6BAE9

Description

@BBC6BAE9

Bug

PluralizeFunction only implements zero, one, and other. The v0_9 spec defines six CLDR plural categories: zero, one, two, few, many, other. The missing three branches make pluralize non-functional for Arabic, Welsh, Polish, Russian, and many other languages.

Spec reference

From basic_catalog.json (v0_9):

"two":  { "description": "String for the 'two' category (used in Arabic, Welsh, etc.)." },
"few":  { "description": "String for the 'few' category (e.g., small groups in Slavic languages)." },
"many": { "description": "String for the 'many' category (e.g., large groups in various languages)." }

Current implementation

packages/genui/lib/src/catalog/basic_functions.dart

// argumentSchema — missing two/few/many entirely
Schema get argumentSchema => S.object(
  properties: {
    'count': S.number(),
    'zero': S.string(),
    'one': S.string(),
    'other': S.string(),   // two, few, many not declared
  },
);

// executeSync — no branch for two/few/many
if (count == 0 && args.containsKey('zero')) return args['zero'];
if (count == 1 && args.containsKey('one')) return args['one'];
return args['other'] ?? '';  // everything else falls here

Comparison with WebCore

WebCore (basic_functions.ts) hard-codes en-US in Intl.PluralRules, which is wrong for non-English locales, but the CLDR category lookup itself works — two/few/many are reachable via the args[rule] lookup. genui does not reach this bar: those categories are absent from both the schema and the implementation.

Related

#902pluralize reads wrong key args["count"] instead of args["value"]

Both issues need to be fixed together for pluralize to be spec-conformant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions