extractPluralCategories static method
Categories used in the first (outermost) {var, plural, …} expression
in message, in source order. Returns null if no plural expression
is found.
Examples:
'{n, plural, =0{x} =1{y} other{z}}' → ['=0', '=1', 'other'].
'Hello {name}' → null.
'{n, plural, zero{…} one{…} two{…} few{…} many{…} other{…}}'
→ ['zero', 'one', 'two', 'few', 'many', 'other'].
Implementation
static List<String>? extractPluralCategories(String message) {
List<String>? found;
_walk(message, (expr) {
if (found != null) return;
if (expr.type == 'plural' || expr.type == 'selectordinal') {
found = expr.branches!.map((b) => b.name).toList();
}
});
return found;
}