\n\n```\n\n \n \n\nTo 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:\n\n```svelte fileName=\"**/*.svelte\"\n\n\n
\n
{$content.totalOpenings(count)}
\n
\n```\n\n \n \n\nTo use plural content in Preact components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"preact\";\nimport { useIntlayer } from \"preact-intlayer\";\n\nconst OpeningsComponent: FC<{ count: number }> = ({ count }) => {\n const { totalOpenings } = useIntlayer(\"total_openings\");\n\n return (\n
\n
{totalOpenings(count)}
\n
\n );\n};\n\nexport default OpeningsComponent;\n```\n\n \n \n\nTo use plural content in SolidJS components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { Component } from \"solid-js\";\nimport { useIntlayer } from \"solid-intlayer\";\n\nconst OpeningsComponent: Component<{ count: number }> = (props) => {\n const { totalOpenings } = useIntlayer(\"total_openings\");\n\n return (\n
\n
{totalOpenings(props.count)}
\n
\n );\n};\n\nexport default OpeningsComponent;\n```\n\n \n \n\nTo use plural content in Angular components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```typescript fileName=\"app.component.ts\" codeFormat=\"typescript\"\nimport { Component, Input } from \"@angular/core\";\nimport { useIntlayer } from \"angular-intlayer\";\n\n@Component({\n selector: \"app-openings\",\n template: `\n
\n
{{ content().totalOpenings(count) }}
\n
\n `,\n})\nexport class OpeningsComponent {\n @Input() count!: number;\n\n content = useIntlayer(\"total_openings\");\n}\n```\n\n \n \n\nTo use plural content with `vanilla-intlayer`, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```typescript fileName=\"**/*.ts\" codeFormat={[\"typescript\", \"esm\"]}\nimport { installIntlayer, useIntlayer } from \"vanilla-intlayer\";\n\ninstallIntlayer();\n\nconst content = useIntlayer(\"total_openings\").onChange((newContent) => {\n document.getElementById(\"openings\")!.textContent =\n newContent.totalOpenings(5);\n});\n\n// Initial render\ndocument.getElementById(\"openings\")!.textContent = content.totalOpenings(5);\n```\n\n \n\n## Quando usare `plural` vs `enu`\n\n\n \n\nTo 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.\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"react\";\nimport { useIntlayer } from \"react-intlayer\";\n\nconst OpeningsComponent: FC<{ count: number }> = ({ count }) => {\n const { totalOpenings } = useIntlayer(\"total_openings\");\n\n return (\n
\n
{totalOpenings(count)}
\n
\n );\n};\n\nexport default OpeningsComponent;\n```\n\n \n \n\nTo use plural content in Next.js Client Components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\n\"use client\";\n\nimport type { FC } from \"react\";\nimport { useIntlayer } from \"next-intlayer\";\n\nconst OpeningsComponent: FC<{ count: number }> = ({ count }) => {\n const { totalOpenings } = useIntlayer(\"total_openings\");\n\n return (\n
\n
{totalOpenings(count)}
\n
\n );\n};\n\nexport default OpeningsComponent;\n```\n\n \n \n\nTo use plural content in Vue components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```vue fileName=\"**/*.vue\"\n\n\n\n
\n
{{ totalOpenings(count) }}
\n
\n\n```\n\n \n \n\nTo 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:\n\n```svelte fileName=\"**/*.svelte\"\n\n\n
\n
{$content.totalOpenings(count)}
\n
\n```\n\n \n \n\nTo use plural content in Preact components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"preact\";\nimport { useIntlayer } from \"preact-intlayer\";\n\nconst OpeningsComponent: FC<{ count: number }> = ({ count }) => {\n const { totalOpenings } = useIntlayer(\"total_openings\");\n\n return (\n
\n
{totalOpenings(count)}
\n
\n );\n};\n\nexport default OpeningsComponent;\n```\n\n \n \n\nTo use plural content in SolidJS components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { Component } from \"solid-js\";\nimport { useIntlayer } from \"solid-intlayer\";\n\nconst OpeningsComponent: Component<{ count: number }> = (props) => {\n const { totalOpenings } = useIntlayer(\"total_openings\");\n\n return (\n
\n
{totalOpenings(props.count)}
\n
\n );\n};\n\nexport default OpeningsComponent;\n```\n\n \n \n\nTo use plural content in Angular components, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```typescript fileName=\"app.component.ts\" codeFormat=\"typescript\"\nimport { Component, Input } from \"@angular/core\";\nimport { useIntlayer } from \"angular-intlayer\";\n\n@Component({\n selector: \"app-openings\",\n template: `\n
\n
{{ content().totalOpenings(count) }}
\n
\n `,\n})\nexport class OpeningsComponent {\n @Input() count!: number;\n\n content = useIntlayer(\"total_openings\");\n}\n```\n\n \n \n\nTo use plural content with `vanilla-intlayer`, retrieve it via the `useIntlayer` hook and call it with a count. Here's an example:\n\n```typescript fileName=\"**/*.ts\" codeFormat={[\"typescript\", \"esm\"]}\nimport { installIntlayer, useIntlayer } from \"vanilla-intlayer\";\n\ninstallIntlayer();\n\nconst content = useIntlayer(\"total_openings\").onChange((newContent) => {\n document.getElementById(\"openings\")!.textContent =\n newContent.totalOpenings(5);\n});\n\n// Initial render\ndocument.getElementById(\"openings\")!.textContent = content.totalOpenings(5);\n```\n\n \n\n\n## Configurazione del contenuto plurale\n\nPer configurare il contenuto plurale nel tuo progetto Intlayer, crea un modulo di contenuto che utilizzi l'helper `plural`. La categoria `other` è obbligatoria e viene utilizzata come fallback quando una locale non definisce una categoria più specifica.\n\n```typescript fileName=\"**/*.content.ts\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\nimport { plural, t, type Dictionary } from \"intlayer\";\n\nconst openingsContent = {\n key: \"total_openings\",\n content: {\n totalOpenings: t({\n en: plural({\n one: \"{{count}} opening\",\n other: \"{{count}} openings\",\n }),\n it: plural({\n one: \"{{count}} posizione aperta\",\n other: \"{{count}} posizioni aperte\",\n }),\n }),\n },\n} satisfies Dictionary;\n\nexport default openingsContent;\n```\n\n```json fileName=\"**/*.content.json\" contentDeclarationFormat=\"json\"\n{\n \"$schema\": \"https://intlayer.org/schema.json\",\n \"key\": \"total_openings\",\n \"content\": {\n \"totalOpenings\": {\n \"nodeType\": \"translation\",\n \"translation\": {\n \"en\": {\n \"nodeType\": \"plural\",\n \"plural\": {\n \"one\": \"{{count}} opening\",\n \"other\": \"{{count}} openings\"\n }\n },\n \"it\": {\n \"nodeType\": \"plural\",\n \"plural\": {\n \"one\": \"{{count}} posizione aperta\",\n \"other\": \"{{count}} posizioni aperte\"\n }\n }\n }\n }\n }\n}\n```\n\n> Le categorie supportate sono `zero`, `one`, `two`, `few`, `many`, `other`. Devi solo dichiarare le categorie utilizzate dalla tua lingua di destinazione, Intlayer torna a `other` quando nessuna categoria specifica corrisponde.\n>\n> Il segnaposto `{{count}}` viene sostituito automaticamente con il conteggio passato in fase di esecuzione. Puoi includere anche altri segnaposto (vedi [Segnaposto personalizzati](#custom-placeholders) sotto).\n\n## Utilizzo del contenuto plurale con React Intlayer\n\nPer utilizzare il contenuto plurale all'interno di un componente React, recuperalo tramite l'hook `useIntlayer` e chiamalo con un conteggio. La locale attiva e il conteggio vengono combinati per scegliere la categoria CLDR corrispondente.\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"react\";\nimport { useIntlayer } from \"react-intlayer\";\n\nconst OpeningsComponent: FC<{ count: number }> = ({ count }) => {\n const { totalOpenings } = useIntlayer(\"total_openings\");\n\n return (\n
\n );\n};\n\nexport default OpeningsComponent;\n```\n\nPuoi chiamare la funzione restituita in due modi equivalenti:\n\n```tsx\ntotalOpenings(21); // abbreviato: solo conteggio\ntotalOpenings({ count: 21 }); // forma esplicita\n```\n\n## Segnaposto personalizzati\n\nLe stringhe plurali possono includere segnaposto diversi da `{{count}}`. Passali sotto forma di oggetto insieme a `count`:\n\n```typescript fileName=\"**/*.content.ts\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\nimport { plural, type Dictionary } from \"intlayer\";\n\nconst inboxContent = {\n key: \"inbox_summary\",\n content: {\n summary: plural({\n one: \"{{name}}, hai {{count}} nuovo messaggio\",\n other: \"{{name}}, hai {{count}} nuovi messaggi\",\n }),\n },\n} satisfies Dictionary;\n\nexport default inboxContent;\n```\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nconst { summary } = useIntlayer(\"inbox_summary\");\n\nsummary({ count: 1, name: \"Alice\" });\n// → \"Alice, hai 1 nuovo messaggio\"\n\nsummary({ count: 7, name: \"Alice\" });\n// → \"Alice, hai 7 nuovi messaggi\"\n```\n\n## Categorie CLDR a colpo d'occhio\n\nLingue diverse utilizzano diversi sottoinsiemi delle categorie CLDR. Alcuni casi comuni:\n\n| Lingua | Categorie utilizzate |\n| ------------------- | -------------------------------------------- |\n| Inglese (`en`) | `one`, `other` |\n| Francese (`fr`) | `one`, `many`, `other` |\n| Russo (`ru`) | `one`, `few`, `many`, `other` |\n| Polacco (`pl`) | `one`, `few`, `many`, `other` |\n| Arabo (`ar`) | `zero`, `one`, `two`, `few`, `many`, `other` |\n| Giapponese / Cinese | solo `other` |\n\nNon è necessario memorizzarlo, dichiara le categorie per le quali hai traduzioni e Intlayer tornerà a `other` quando necessario.\n\n## Limitazione\n\nA differenza di altri nodi, il nodo `plural` non può ancora essere nidificato con nodi figli.\n\nEsempio:\n\nValido:\n\n```ts\n totalOpenings: t({\n en: plural({\n one: \"{{count}} opening\",\n other: \"{{count}} openings\",\n }),\n fr: plural({\n one: \"{{count}} offre\",\n other: \"{{count}} offres\",\n }),\n }),\n```\n\nNon valido:\n\n```ts\ntotalOpenings: plural({\n one: t({\n en: \"{{count}} opening\",\n fr: \"{{count}} offre\",\n }),\n other: t({\n en: \"{{count}} openings\",\n fr: \"{{count}} offres\",\n }),\n}),\n```\n\n## Risorse aggiuntive\n\nPer informazioni più dettagliate sulla configurazione e l'utilizzo, fare riferimento alle seguenti risorse:\n\n- [Documentazione sull'enumerazione](/it/doc/concept/content/enumeration)\n- [Documentazione sull'inserimento](/it/doc/concept/content/insertion)\n- [Documentazione della CLI Intlayer](/it/doc/concept/cli)\n- [Documentazione React Intlayer](/it/doc/environment/create-react-app)\n- [Documentazione Next Intlayer](/it/doc/environment/nextjs/15)\n\nQueste risorse offrono ulteriori approfondimenti sulla configurazione e l'utilizzo di Intlayer in vari ambienti e framework.\n","description":"Scopri come dichiarare e utilizzare contenuti plurali basati sulla localizzazione (basati su CLDR) nel tuo sito web multilingue. Segui i passaggi in questa documentazione online per configurare il tuo progetto in pochi minuti.","url":"https://intlayer.org/it/doc/concept/content/plural","datePublished":"2026-05-04","dateModified":"2026-05-04","version":"8.8.0","keywords":"Plurale, Pluralizzazione, CLDR, Internazionalizzazione, Documentazione, Intlayer, Next.js, JavaScript, React","license":"https://raw.githubusercontent.com/aymericzip/intlayer/refs/heads/main/LICENSE","audience":{"@type":"Audience","audienceType":"Sviluppatori, Manager dei contenuti"}}
Copia il Markdown del documento nella porta-documenti
Contenuto Plurale / Il plurale in Intlayer
Come funziona il plurale
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
Copiare il codice
Copiare il codice nella clipboard
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;
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
Copiare il codice
Copiare il codice nella clipboard
"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;
To use plural content in Vue components, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
**/*.vue
Copiare il codice
Copiare il codice nella clipboard
<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>
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
Copiare il codice
Copiare il codice nella clipboard
<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>
To use plural content in Preact components, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
**/*.tsx
Copiare il codice
Copiare il codice nella clipboard
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;
To use plural content in SolidJS components, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
**/*.tsx
Copiare il codice
Copiare il codice nella clipboard
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;
To use plural content in Angular components, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
app.component.ts
Copiare il codice
Copiare il codice nella clipboard
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");}
To use plural content with vanilla-intlayer, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
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
Copiare il codice
Copiare il codice nella clipboard
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;
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
Copiare il codice
Copiare il codice nella clipboard
"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;
To use plural content in Vue components, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
**/*.vue
Copiare il codice
Copiare il codice nella clipboard
<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>
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
Copiare il codice
Copiare il codice nella clipboard
<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>
To use plural content in Preact components, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
**/*.tsx
Copiare il codice
Copiare il codice nella clipboard
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;
To use plural content in SolidJS components, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
**/*.tsx
Copiare il codice
Copiare il codice nella clipboard
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;
To use plural content in Angular components, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
app.component.ts
Copiare il codice
Copiare il codice nella clipboard
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");}
To use plural content with vanilla-intlayer, retrieve it via the useIntlayer hook and call it with a count. Here's an example:
Per configurare il contenuto plurale nel tuo progetto Intlayer, crea un modulo di contenuto che utilizzi l'helper plural. La categoria other è obbligatoria e viene utilizzata come fallback quando una locale non definisce una categoria più specifica.
Le categorie supportate sono zero, one, two, few, many, other. Devi solo dichiarare le categorie utilizzate dalla tua lingua di destinazione, Intlayer torna a other quando nessuna categoria specifica corrisponde.
Il segnaposto {{count}} viene sostituito automaticamente con il conteggio passato in fase di esecuzione. Puoi includere anche altri segnaposto (vedi Segnaposto personalizzati sotto).
Utilizzo del contenuto plurale con React Intlayer
Per utilizzare il contenuto plurale all'interno di un componente React, recuperalo tramite l'hook useIntlayer e chiamalo con un conteggio. La locale attiva e il conteggio vengono combinati per scegliere la categoria CLDR corrispondente.