Pluralization & Gender
Pluralisasi bukan sekadar "1 = singular, 2+ = plural". Bahasa Arab punya 6 bentuk plural, Rusia punya 3, dan Jepang tidak punya plural sama sekali. ICU Message Format adalah standar industri untuk menangani ini.
Plural Rules per Bahasa
// English: 2 forms (one, other)
"1 item" / "5 items"
// Indonesian: 1 form (other) — tidak ada plural marker
"1 item" / "5 item"
// Russian: 3 forms (one, few, many)
"1 файл" / "2 файла" / "5 файлов"
// Arabic: 6 forms (zero, one, two, few, many, other)
// Masing-masing punya aturan sendiri
ICU Message Format — Plural
// ICU plural syntax
{count, plural,
=0 {Tidak ada pesan}
one {# pesan}
other {# pesan}
}
// Contoh di JSON
{
"notifications": "{count, plural, =0 {Tidak ada notifikasi} one {# notifikasi baru} other {# notifikasi baru}}",
"cart": "{count, plural, =0 {Keranjang kosong} other {# barang di keranjang}}"
}
// English version
{
"notifications": "{count, plural, =0 {No notifications} one {# new notification} other {# new notifications}}",
"cart": "{count, plural, =0 {Cart is empty} one {# item in cart} other {# items in cart}}"
}
ICU Message Format — Select (Gender)
// Gender selection
{gender, select,
male {Dia mengirim pesannya}
female {Dia mengirim pesannya}
other {Mereka mengirim pesannya}
}
// Contoh JSON
{
"profile_update": "{gender, select, male {Dia memperbarui profilnya} female {Dia memperbarui profilnya} other {Pengguna memperbarui profilnya}}"
}
// English — gender matters more
{
"profile_update": "{gender, select, male {He updated his profile} female {She updated her profile} other {They updated their profile}}"
}
Nested ICU: Plural + Select
// Combine plural dan select
{
"liked": "{gender, select,
female {{count, plural,
one {{name} menyukai fotomu}
other {{name} dan # orang lainnya menyukai fotomu}
}}
male {{count, plural,
one {{name} menyukai fotomu}
other {{name} dan # orang lainnya menyukai fotomu}
}}
other {{count, plural,
one {{name} menyukai fotomu}
other {{name} dan # orang lainnya menyukai fotomu}
}}
}"
}
i18next Pluralization
// i18next menggunakan suffix _one, _other, dll
// en/translation.json
{
"item": "{{count}} item",
"item_other": "{{count}} items",
"item_zero": "No items"
}
// id/translation.json — bahasa Indonesia tidak punya plural form
{
"item_other": "{{count}} item"
}
// Usage
t("item", { count: 0 }) // "No items" (en) / "0 item" (id)
t("item", { count: 1 }) // "1 item" (en) / "1 item" (id)
t("item", { count: 5 }) // "5 items" (en) / "5 item" (id)
Ordinal Numbers
// English ordinals: 1st, 2nd, 3rd, 4th...
{count, selectordinal,
one {#st}
two {#nd}
few {#rd}
other {#th}
}
// "1st place", "2nd place", "3rd place", "4th place"