Handle plural forms correctly using CLDR (Common Locale Data Repository) rules.
Different languages have different plural rules. English has 2 forms (singular/plural), but other languages can have more:
- English: 1 item, 2 items
- Polish: 1 przedmiot, 2 przedmioty, 5 przedmiotów (3 forms!)
- Arabic: 0 عناصر, 1 عنصر, 2 عنصران, 3 عناصر, 11 عنصرًا, 100 عنصر (6 forms!)
Roblox Slang uses CLDR rules to handle this automatically.
{
"items": {
"zero": "No items",
"one": "1 item",
"other": "{count} items"
}
}Usage:
local t = Translations.new("en")
print(t.items(0)) -- "No items"
print(t.items(1)) -- "1 item"
print(t.items(5)) -- "5 items"
print(t.items(100)) -- "100 items"{
"items": {
"one": "1 artículo",
"other": "{count} artículos"
}
}Usage:
local t = Translations.new("es")
print(t.items(1)) -- "1 artículo"
print(t.items(5)) -- "5 artículos"Roblox Slang supports all 6 CLDR plural categories:
| Category | Description | Example (English) |
|---|---|---|
zero |
Exactly zero | 0 items |
one |
Singular | 1 item |
two |
Exactly two | 2 items (some languages) |
few |
Small number | 3-10 items (some languages) |
many |
Large number | 11+ items (some languages) |
other |
Default/fallback | Any other count |
Note: Not all languages use all categories. English only uses one and other.
Rules:
one: n = 1other: everything else
{
"items": {
"one": "1 item",
"other": "{count} items"
}
}Rules:
one: n = 1other: everything else
{
"items": {
"one": "1 artículo",
"other": "{count} artículos"
}
}Rules:
other: all numbers (no singular/plural distinction)
{
"items": {
"other": "{count} item"
}
}Rules:
one: n = 1few: n = 2-4, 22-24, 32-34, etc.many: n = 0, 5-21, 25-31, etc.other: fractions
{
"items": {
"one": "1 przedmiot",
"few": "{count} przedmioty",
"many": "{count} przedmiotów",
"other": "{count} przedmiotu"
}
}Rules:
zero: n = 0one: n = 1two: n = 2few: n = 3-10many: n = 11-99other: n = 100+, fractions
{
"items": {
"zero": "لا عناصر",
"one": "عنصر واحد",
"two": "عنصران",
"few": "{count} عناصر",
"many": "{count} عنصرًا",
"other": "{count} عنصر"
}
}Combine pluralization with other parameters:
{
"playerItems": {
"one": "{name} has 1 item",
"other": "{name} has {count} items"
}
}Usage:
print(t.playerItems(1, { name = "Player1" }))
-- "Player1 has 1 item"
print(t.playerItems(5, { name = "Player1" }))
-- "Player1 has 5 items"Use zero for special handling of zero:
{
"coins": {
"zero": "No coins",
"one": "1 coin",
"other": "{count} coins"
}
}Usage:
print(t.coins(0)) -- "No coins" (not "0 coins")
print(t.coins(1)) -- "1 coin"
print(t.coins(5)) -- "5 coins"Plurals can be nested in objects:
{
"inventory": {
"items": {
"one": "1 item",
"other": "{count} items"
},
"weapons": {
"one": "1 weapon",
"other": "{count} weapons"
}
}
}Usage:
print(t.inventory:items(5)) -- "5 items"
print(t.inventory:weapons(1)) -- "1 weapon"Use format specifiers to control number formatting:
{
"price": {
"one": "${amount:fixed} for 1 item",
"other": "${amount:fixed} for {count} items"
}
}Usage:
print(t.price(1, { amount = 9.99 }))
-- "$9.99 for 1 item"
print(t.price(5, { amount = 49.95 }))
-- "$49.95 for 5 items"The other category is required as fallback:
{
"items": {
"one": "1 item",
"other": "{count} items" // Required!
}
}Instead of "0 items", use more natural language:
{
"items": {
"zero": "No items", // Better UX
"one": "1 item",
"other": "{count} items"
}
}Test your plurals with various numbers:
- 0 (zero)
- 1 (one)
- 2 (two, if applicable)
- 3-10 (few, if applicable)
- 11-99 (many, if applicable)
- 100+ (other)
Always check CLDR rules for your target language:
Don't hardcode "1" in translations:
❌ Bad:
{
"items": {
"one": "1 item",
"other": "{count} items"
}
}✅ Good:
{
"items": {
"one": "{count} item", // Use {count} even for singular
"other": "{count} items"
}
}This allows flexibility for languages where "1" might be displayed differently.
Validate your plural translations:
roblox-slang validateThis checks:
- All plural forms have
othercategory - Plural categories are valid for the locale
- Parameters are consistent across categories
❌ Wrong:
{
"items": {
"one": "1 item"
// Missing "other"!
}
}✅ Correct:
{
"items": {
"one": "1 item",
"other": "{count} items"
}
}❌ Wrong (English doesn't use few):
{
"items": {
"one": "1 item",
"few": "{count} items", // English doesn't have "few"
"other": "{count} items"
}
}✅ Correct:
{
"items": {
"one": "1 item",
"other": "{count} items"
}
}❌ Wrong:
{
"items": {
"one": "{name} has 1 item",
"other": "{count} items" // Missing {name}!
}
}✅ Correct:
{
"items": {
"one": "{name} has 1 item",
"other": "{name} has {count} items"
}
}| Locale | Categories Used |
|---|---|
| English (en) | one, other |
| Spanish (es) | one, other |
| Indonesian (id) | other |
| Portuguese (pt) | one, other |
| German (de) | one, other |
| French (fr) | one, other |
| Japanese (ja) | other |
| Korean (ko) | other |
| Chinese (zh) | other |
| Polish (pl) | one, few, many, other |
| Russian (ru) | one, few, many, other |
| Arabic (ar) | zero, one, two, few, many, other |
For complete rules, see CLDR Plural Rules.
- Getting Started - Initial setup
- String Interpolation - Parameter usage
- Configuration - Config options
- Rojo Integration - Use with Rojo
- CLDR Plural Rules - Official reference