Idiom.PluralPreprocess (idiom v0.1.0)

Preprocessor for language-specific pluralization rules.

Idiom uses Unicode CLDR plural rules, which they provide for download as a JSON file. This is stored in our priv directory. The Plural and PluralPreprocess modules use these definitions to generate Elixir ASTs representing a cond statement for each language, which are then used at compile-time to generate functions. This module builds on a lexer and parser inside the src/ directory to generate the ASTs.

Summary

Functions

Parses a list of plural rules and converts them into a :cond expression, with the clauses sorted by plural suffix.

Functions

Link to this function

parse_rules(rules)

Parses a list of plural rules and converts them into a :cond expression, with the clauses sorted by plural suffix.

Examples

iex> Idiom.PluralPreprocess.parse_rules([{"pluralRule-count-one", "n = 1"}])
{:cond, [], [[do: [{:->, [], [[{:==, [], [{:n, [], nil}, 1]}], "one"]}]]]}