Skip to content

0.7.0

Compare
Choose a tag to compare
@QuiiBz QuiiBz released this 28 Jul 06:58
· 83 commits to main since this release

Plurals

Plural translations work out of the box without any external dependencies, using the Intl.PluralRules API, which is supported in all browsers and Node.js.

To declare plural translations, append # followed by zero, one, two, few, many or other:

// locales/en.ts
export default {
  'cows#one': 'A cow',
  'cows#other': '{count} cows'
} as const

The correct translation will then be determined automatically using a mandatory count parameter. This works with the Pages Router, App Router in both Client and Server Components, and with scoped translations:

export default function Page() {
  const t = useI18n()

  return (
    <div>
      {/* Output: A cow */}
      <p>{t('cows', { count: 1 })}</p>
      {/* Output: 3 cows */}
      <p>{t('cows', { count: 3 })}</p>
    </div>
  )
}

What's Changed

  • chore(next-international): remove peer dependencies by @QuiiBz in #76
  • feat: add plurals support by @QuiiBz in #75
  • feat: typesafe plural count by @QuiiBz in #78

Full Changelog: 0.6.4...0.7.0