Loading repository data…
Loading repository data…
sanyabeast / repository
Lightweight JavaScript library for handling pluralization in multiple languages with a rule-based approach. Supports complex pluralization rules for any language, works in browser and Node.js environments, has zero dependencies, and includes an interactive demo.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A lightweight JavaScript library for handling pluralization in multiple languages with a rule-based approach.
// Set pluralization rules
pluralizer.setRules("ends(1)#ends(range(2,4))#or(ends(range(5, 19)), ends(0))");
// Use the rules with variables
const result = pluralizer.make("#{яблоко@яблока@яблок?count}", { count: 5 });
// result: "яблок"
The library supports various expressions for defining pluralization rules:
ends(value) - Checks if the number ends with the specified valuerange(from, to) - Creates a range of numbersor(expr1, expr2) - Logical OR between expressionsand(expr1, expr2) - Logical AND between expressionsequals(value) - Checks if the number equals the specified valueany() - Matches any valueTemplates use the following format: #{form1@form2@form3?variable}
Where:
form1, form2, form3 are different word formsvariable is the variable name to check against the rulesOpen index.html in your browser to try the interactive demo.
MIT