pysepal.i18n.flatten.flatten_document#
- pysepal.i18n.flatten.flatten_document(document, *, locale, source, authoritative)[source]#
Return the flat messages and plural base keys of one JSON document.
- Parameters:
document (Any) – The parsed JSON value; it must be an object.
locale (str) – The locale the document belongs to, used in error messages.
source (str) – The file name, used in error messages.
authoritative (bool) – True for English, which defines message identities and named arguments. Translations may use their own plural categories.
- Returns:
A
(messages, plural_keys)pair.messagesmaps a dotted key to a message; a plural node contributes one key per category, for examplechips.models.one.plural_keysholds those nodes’ base keys, for examplechips.models.- Raises:
CatalogError – The document is not an object, a key segment contains a dot, or a leaf is not a string. In English only: a plural node does not hold exactly the string leaves named in
oneandother, a leaf uses unsupported template syntax, or a leaf uses a positional placeholder ({}or{0}).- Return type:
Tuple[Dict[str, str], FrozenSet[str]]