Skip to content

Component: Plural (CLDR plural rules) #34

Open

Description

@sapatmohit

Component: Plural (CLDR plural rules)

Build a small component that picks the right plural form for a count based on the locale's CLDR rules.

Requirements

  • TypeScript-first with exported props interface
  • Uses Intl.PluralRules under the hood (cardinal by default, type="ordinal" supported)
  • Supports all CLDR categories: zero, one, two, few, many, other (other required)
  • Exact-match overrides like =0
  • Optional # placeholder replaced with the locale-formatted number (Intl.NumberFormat)
  • Works as a server-safe render (no state needed)
  • Tailwind CSS compatible

Expected API

<Plural
  count={3}
  locale="ar"
  zero="لا ملفات"
  one="ملف واحد"
  two="ملفان"
  few="# ملفات"
  many="# ملفًا"
  other="# ملف"
/>

Deliverables

  • Component source in src/registry/components/
  • Export in src/registry/components/index.ts and entry in src/registry/registry.ts
  • Tests in test/ covering at least en, ar, pl, ru and ordinal en
  • Documentation page in content/docs/components/

See CONTRIBUTING.md.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    componentNew or modified componentgood first issueGood for newcomerspluralizationPluralization and CLDR rule components

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions