in python/moz/l10n/formats/android/serialize.py [0:0]
def set_plural_message(plurals: etree._Element, msg: SelectMessage) -> None:
sel = msg.selector_expressions()[0] if len(msg.selectors) == 1 else None
if len(msg.declarations) != 1 or not sel or sel.function != "number":
raise ValueError(f"Unsupported message: {msg}")
for keys, value in msg.variants.items():
key = keys[0] if len(keys) == 1 else None
if isinstance(key, CatchallKey):
key = key.value or "other"
if key not in plural_categories:
raise ValueError(f"Unsupported plural variant key: {keys}")
item = etree.SubElement(plurals, "item", attrib={"quantity": key})
set_pattern(item, value)
item.tail = "\n "
item.tail = "\n "