aymericzip/intlayer-skills / skills/intlayer-content
intlayer-content
VerifiedDefine rich content structures using Intlayer content nodes. Use when the user asks to "create translations", "handle pluralization", "use markdown in content", or implement "conditional content".
| File | Kind | Size |
|---|---|---|
| LICENCE.md | markdown | 10.7 KB |
| SKILL.md | skill md | 12.0 KB |
| references/concept_content.md | markdown | 35.4 KB |
| references/concept_content_condition.md | markdown | 7.7 KB |
| references/concept_content_enumeration.md | markdown | 13.6 KB |
| references/concept_content_file.md | markdown | 8.4 KB |
| references/concept_content_function-fetching.md | markdown | 4.6 KB |
| references/concept_content_gender.md | markdown | 7.9 KB |
| references/concept_content_html.md | markdown | 22.7 KB |
| references/concept_content_insertion.md | markdown | 4.7 KB |
| references/concept_content_markdown.md | markdown | 47.2 KB |
| references/concept_content_nesting.md | markdown | 8.7 KB |
| references/concept_content_plural.md | markdown | 11.3 KB |
| references/concept_content_select.md | markdown | 10.6 KB |
| references/concept_content_translation.md | markdown | 6.1 KB |
| references/concept_per-locale-file.md | markdown | 7.6 KB |
| references/packages_intlayer_exports.md | markdown | 12.4 KB |
references/concept_content_plural.md
View on GitHub---
createdAt: 2026-05-04
updatedAt: 2026-09-27
priority: 8
title: "Plural Content: CLDR Plural Rules"
description: "Declare locale-aware plurals in Intlayer with CLDR categories (zero, one, two, few, many, other) resolved from a count at runtime."
keywords:
- Plural
- Pluralization
- CLDR
- Internationalization
- Documentation
- Intlayer
- Next.js
- JavaScript
- React
slugs:
- doc
- concept
- content
- plural
history:
- version: 8.8.0
date: 2026-05-04
changes: "Init history"
author: aymericzip
---
# Plural Content / Plural in Intlayer
## How Plural Works
In Intlayer, plural content is achieved through the `plural` function, which maps CLDR plural categories, `zero`, `one`, `two`, `few`, `many`, `other`, to their corresponding content. The correct category is selected automatically based on the active locale and a count value, using the platform's built-in [`Intl.PluralRules`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules) API.
Unlike [`enu`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/enumeration.md), which selects content based on numeric ranges you define yourself, `plural` delegates the selection to CLDR rules. This is what makes it scalable to languages with complex pluralization rules, such as Russian, Polish, Arabic, or Welsh, without having to hand-write modulo logic.
- [`enu`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/enumeration.md)
## When to Use `plural` vs `enu`
| Use case | Helper |
| ------------------------------------------------------------------------ | -------- |
| Locale-aware grammatical plural forms (one apple / two apples / 5 яблок) | `plural` |
| Custom numeric ranges (`<5`, `>=10`) or non-CLDR buckets | `enu` |
If you only target English (which has just `one` / `other`), either works. For any language with `few` / `many` / `two` distinctions, prefer `plural`.
## Setting Up Plural Content
To set up plural content in your Intlayer project, create a content module that uses the `plural` helper. The `other` category is required and is used as the fallback when a locale doesn't define a more specific category.
```typescript fileName="**/*.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
import { plural, t, type Dictionary } from "intlayer";
const openingsContent = {
key: "total_openings",
content: {
totalOpenings: t({
en: plural({
one: "{{count}} opening",
other: "{{count}} openings",
}),
ru: plural({
one: "{{count}} вакансия",
few: "{{count}} вакансии",
many: "{{count}} вакансий",
other: "{{count}} вакансий",
}),
}),
},
} satisfies Dictionary;
export default openingsContent;
```
```json fileName="**/*.content.json" contentDeclarationFormat="json"
{
"$schema": "https://intlayer.org/schema.json",
"key": "total_openings",
"content": {
"totalOpenings": {
"nodeType": "translation",
"translation": {
"en": {
"nodeType": "plural",
"plural": {
"one": "{{count}} opening",
"other": "{{count}} openings"
}
},
"ru": {
"nodeType": "plural",
"plural": {
"one": "{{count}} вакансия",
"few": "{{count}} вакансии",
"many": "{{count}} вакансий",
"other": "{{count}} вакансий"
}
}
}
}
}
}
```
> The supported categories are `zero`, `one`, `two`, `few`, `many`, `other`. You only need to declare the categories your target language uses, Intlayer falls back to `other` when no specific category matches.
>
> The `{{count}}` placeholder is automatically replaced with the count you pass at runtime. You can include other placeholders too (see [Custom placeholders](#custom-placeholders) below).
## Using Plural Content
<Tabs group="framework">
<Tab label="React" value="react">
To use plural content inside a React component, retrieve it via the `useIntlayer` hook and call it with a count. The active locale and the count are combined to pick the matching CLDR category.
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
import type { FC } from "react";
import { useIntlayer } from "react-intlayer";
const OpeningsComponent: FC<{ count: number }> = ({ count }) => {
const { totalOpenings } = useIntlayer("total_openings");
return (
<div>
<p>{totalOpenings(count)}</p>
</div>
);
};
export default OpeningsComponent;
```
</Tab>
<Tab label="Next.js" value="nextjs">
To use plural content in Next.js Client Components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
"use client";
import type { FC } from "react";
import { useIntlayer } from "next-intlayer";
const OpeningsComponent: FC<{ count: number }> = ({ count }) => {
const { totalOpenings } = useIntlayer("total_openings");
return (
<div>
<p>{totalOpenings(count)}</p>
</div>
);
};
export default OpeningsComponent;
```
</Tab>
<Tab label="Vue" value="vue">
To use plural content in Vue components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:
```vue fileName="**/*.vue"
<script setup lang="ts">
import { useIntlayer } from "vue-intlayer";
defineProps<{ count: number }>();
const { totalOpenings } = useIntlayer("total_openings");
</script>
<template>
<div>
<p>{{ totalOpenings(count) }}</p>
</div>
</template>
```
</Tab>
<Tab label="Svelte" value="svelte">
To use plural content in Svelte components, retrieve it via the `useIntlayer` hook and call it with a count. The store is accessed with `$`. Here's an example:
```svelte fileName="**/*.svelte"
<script lang="ts">
import { useIntlayer } from "svelte-intlayer";
export let count: number;
const content = useIntlayer("total_openings");
</script>
<div>
<p>{$content.totalOpenings(count)}</p>
</div>
```
</Tab>
<Tab label="Preact" value="preact">
To use plural content in Preact components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
import type { FC } from "preact";
import { useIntlayer } from "preact-intlayer";
const OpeningsComponent: FC<{ count: number }> = ({ count }) => {
const { totalOpenings } = useIntlayer("total_openings");
return (
<div>
<p>{totalOpenings(count)}</p>
</div>
);
};
export default OpeningsComponent;
```
</Tab>
<Tab label="Solid" value="solid">
To use plural content in SolidJS components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
import type { Component } from "solid-js";
import { useIntlayer } from "solid-intlayer";
const OpeningsComponent: Component<{ count: number }> = (props) => {
const { totalOpenings } = useIntlayer("total_openings");
return (
<div>
<p>{totalOpenings(props.count)}</p>
</div>
);
};
export default OpeningsComponent;
```
</Tab>
<Tab label="Angular" value="angular">
To use plural content in Angular components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:
```typescript fileName="app.component.ts" codeFormat="typescript"
import { Component, Input } from "@angular/core";
import { useIntlayer } from "angular-intlayer";
@Component({
selector: "app-openings",
template: `
<div>
<p>{{ content().totalOpenings(count) }}</p>
</div>
`,
})
export class OpeningsComponent {
@Input() count!: number;
content = useIntlayer("total_openings");
}
```
</Tab>
<Tab label="Vanilla JS" value="vanilla">
To use plural content with `vanilla-intlayer`, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:
```typescript fileName="**/*.ts" codeFormat={["typescript", "esm"]}
import { installIntlayer, useIntlayer } from "vanilla-intlayer";
installIntlayer();
const content = useIntlayer("total_openings").onChange((newContent) => {
document.getElementById("openings")!.textContent =
newContent.totalOpenings(5);
});
// Initial render
document.getElementById("openings")!.textContent = content.totalOpenings(5);
```
</Tab>
</Tabs>
## Custom placeholders
Plural strings can include placeholders other than `{{count}}`. Pass them in the object form alongside `count`:
```typescript fileName="**/*.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
import { plural, type Dictionary } from "intlayer";
const inboxContent = {
key: "inbox_summary",
content: {
summary: plural({
one: "{{name}}, you have {{count}} new message",
other: "{{name}}, you have {{count}} new messages",
}),
},
} satisfies Dictionary;
export default inboxContent;
```
```tsx fileName="**/*.tsx" codeFormat={["typescript", "esm"]}
const { summary } = useIntlayer("inbox_summary");
summary({ count: 1, name: "Alice" });
// → "Alice, you have 1 new message"
summary({ count: 7, name: "Alice" });
// → "Alice, you have 7 new messages"
```
## CLDR Categories at a Glance
Different languages use different subsets of the CLDR categories. A few common cases:
| Language | Categories used |
| ------------------ | -------------------------------------------- |
| English (`en`) | `one`, `other` |
| French (`fr`) | `one`, `many`, `other` |
| Russian (`ru`) | `one`, `few`, `many`, `other` |
| Polish (`pl`) | `one`, `few`, `many`, `other` |
| Arabic (`ar`) | `zero`, `one`, `two`, `few`, `many`, `other` |
| Japanese / Chinese | `other` only |
You don't need to memorize this, declare the categories you have translations for, and Intlayer will fall back to `other` when needed.
## Limitation
In comparison to other nodes, `plural` cannot be imbricated with children nodes yet.
Example:
Valid:
```ts
totalOpenings: t({
en: plural({
one: "{{count}} opening",
other: "{{count}} openings",
}),
fr: plural({
one: "{{count}} offre",
other: "{{count}} offres",
}),
}),
```
Invalid:
```ts
totalOpenings: plural({
one: t({
en: "{{count}} opening",
fr: "{{count}} offre",
}),
other: t({
en: "{{count}} openings",
fr: "{{count}} offres",
}),
}),
```
## Additional Resources
For more detailed information on configuration and usage, refer to the following resources:
- [Enumeration Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/enumeration.md)
- [Insertion Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/insertion.md)
- [Intlayer CLI Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/index.md)
- [React Intlayer Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_create_react_app.md)
- [Next Intlayer Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nextjs_15.md)
These resources offer further insights into the setup and usage of Intlayer across various environments and frameworks.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |