
CLDR 복수형 규칙: 언어별 i18n 복수형 범주 검증
영어에는 복수형이 2가지, 아랍어에는 6가지, 러시아어에는 4가지 있어요. i18n 설정이 'one'과 'other'만 처리한다면 대부분 언어에서 앱이 제대로 작동하지 않아요. 이 가이드에서 CLDR 복수형 규칙과 검증 방법을 알아보세요.
CLDR 복수형 규칙이란?
Unicode CLDR(Common Locale Data Repository)은 zero, one, two, few, many, other라는 6가지 복수형 범주를 정의해요. 모든 언어는 고유한 숫자 규칙에 따라 이 범주의 일부를 사용해요. 영어는 one(정확히 1)과 other(나머지)를 사용하지만 대부분 언어는 더 복잡해요. 복수형이 잘못되면 문법이 어색해져 앱이 전문적이지 않게 보여요.
// English has 2 plural forms: one, other
// "1 item" vs "2 items"
// But many languages have more:
// Arabic: 6 forms (zero, one, two, few, many, other)
// Polish: 3 forms (one, few, other)
// Japanese: 1 form (other)
// Czech: 3 forms (one, few, other)
// If you only provide "one" and "other",
// Arabic and Polish users see broken text.6가지 복수형 범주
CLDR은 정확히 6가지 복수형 범주를 정의해요. 모든 언어가 6가지를 전부 사용하지는 않아요. 영어는 2가지만, 아랍어는 6가지를 모두 사용해요. i18n 파일에 대상 언어별 필수 범주를 정의하지 않으면 앱이 중단되거나 사용자에게 원시 키 또는 문법적으로 잘못된 텍스트가 표시돼요.
// CLDR defines 6 plural categories:
// zero - 0 items (Arabic, Latvian)
// one - 1 item (most languages)
// two - 2 items (Arabic, Welsh)
// few - 2-4 items (Polish, Czech, Russian)
// many - 5-19 items (Arabic, Polish, Russian)
// other - everything else (required for ALL languages)
// Examples by language:
// English: one, other (2 forms)
// French: one, many, other (3 forms)
// Arabic: zero, one, two, few, many, other (6 forms)
// Japanese: other (1 form)
// Polish: one, few, many, other (4 forms)
// Russian: one, few, many, other (4 forms)언어별 복수형 범주
일반적인 대상 언어에 필요한 복수형 범주를 빠르게 확인할 수 있는 표예요. 번역 파일에 복수형을 정의할 때 사용하세요.
// MISTAKE 1: Only providing "one" and "other"
// en.json
{
"items_one": "{{count}} item",
"items_other": "{{count}} items"
}
// This breaks for Arabic (missing zero, two, few, many)
// MISTAKE 2: Hardcoded plural logic
// WRONG:
const text = count === 1 ? "1 item" : `${count} items`
// This fails for languages where "1" isn't the only "one" form
// MISTAKE 3: Missing "other" category
// "other" is REQUIRED for every language
// Without it, some numbers show raw keys
// MISTAKE 4: Translating plural RULES instead of text
// The CLDR rules (one, few, many) are universal
// Only the TEXT after each rule should be translated복수형 자동 검증
i18n-validate는 번역 파일의 모든 복수형 키에 대상 언어가 요구하는 CLDR 범주가 전부 정의되어 있는지 확인해요. 러시아어 파일에 'one'과 'other'만 있으면 누락된 'few'와 'many' 범주를 오류로 표시해요. CI에서 실행해 사용자에게 도달하기 전에 복수형 문제를 찾아내세요.
# Validate plural forms match CLDR requirements
npx i18n-validate --check-plurals \
--source locales/en.json \
--targets 'locales/*.json'
# Output:
# locales/ar.json:
# items: missing plural forms: zero, two, few, many
# Expected: zero, one, two, few, many, other
# Found: one, other
#
# locales/pl.json:
# items: missing plural forms: few, many
# Expected: one, few, many, other
# Found: one, other
# Fix: Add all required forms for each language
# See https://unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html복수형용 ICU MessageFormat
복수형 번역을 정의하는 권장 방식은 ICU MessageFormat이에요. 복수형 규칙이 삽입된 단일 문자열을 사용해요: {count, plural, one {# item} other {# items}'}. ICU는 react-intl, vue-i18n, Angular Transloco, Flutter 등 대부분의 최신 i18n 프레임워크에서 지원해요.
// ICU MessageFormat handles plurals correctly
// It uses CLDR rules internally
// en.json
{
"items": "{count, plural, one {# item} other {# items}}"
}
// ar.json
{
"items": "{count, plural, zero {لا عناصر} one {عنصر واحد} two {عنصران} few {# عناصر} many {# عنصرًا} other {# عنصر}}"
}
// pl.json
{
"items": "{count, plural, one {# element} few {# elementy} many {# elementów} other {# elementu}}"
}
// ICU also handles ordinals:
{
"ranking": "{pos, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}"
}# Validate ICU message syntax
npx i18n-validate --check-icu \
--source locales/en.json \
--targets 'locales/*.json'
# Catches:
# - Missing plural categories for the target language
# - Syntax errors in ICU messages
# - Mismatched variable names
# - Missing "other" (always required)지금 i18n Agent 사용해 보기
번역 파일을 여기에 드롭
JSON, YAML, PO, XML, CSV, Markdown, Properties
또는 클릭하여 파일 선택
대상 언어