\n\n\n```\n\n \n \n\nTo use enumeration in Svelte components, retrieve it via the `useIntlayer` hook. The store is accessed with `$`. Here's an example:\n\n```svelte fileName=\"**/*.svelte\"\n\n\n
\n

{$content.numberOfCar(6)}

\n
\n```\n\n
\n \n\nTo use enumeration in Preact components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"preact\";\nimport { useIntlayer } from \"preact-intlayer\";\n\nconst CarComponent: FC = () => {\n const { numberOfCar } = useIntlayer(\"car_count\");\n\n return (\n
\n

{numberOfCar(6)}

\n
\n );\n};\n\nexport default CarComponent;\n```\n\n
\n \n\nTo use enumeration in SolidJS components, retrieve it via the `useIntlayer` hook. 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 CarComponent: Component = () => {\n const { numberOfCar } = useIntlayer(\"car_count\");\n\n return (\n
\n

{numberOfCar(6)}

\n
\n );\n};\n\nexport default CarComponent;\n```\n\n
\n \n\nTo use enumeration in Angular components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```typescript fileName=\"app.component.ts\" codeFormat=\"typescript\"\nimport { Component } from \"@angular/core\";\nimport { useIntlayer } from \"angular-intlayer\";\n\n@Component({\n selector: \"app-car\",\n template: `\n
\n

{{ content().numberOfCar(6) }}

\n
\n `,\n})\nexport class CarComponent {\n content = useIntlayer(\"car_count\");\n}\n```\n\n
\n \n\nTo use enumeration with `vanilla-intlayer`, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```typescript fileName=\"**/*.ts\" codeFormat={[\"typescript\", \"esm\"]}\nimport { installIntlayer, useIntlayer } from \"vanilla-intlayer\";\n\ninstallIntlayer();\n\nconst content = useIntlayer(\"car_count\").onChange((newContent) => {\n document.getElementById(\"cars\")!.textContent = newContent.numberOfCar(6);\n});\n\n// Initial render\ndocument.getElementById(\"cars\")!.textContent = content.numberOfCar(6);\n```\n\n \n\n\n## Dodatkowe zasoby\n\nAby uzyskać bardziej szczegółowe informacje na temat konfiguracji i użytkowania, zapoznaj się z następującymi zasobami:\n\n- [Dokumentacja Intlayer CLI](/pl/doc/concept/cli)\n- [Dokumentacja React Intlayer](/pl/doc/environment/create-react-app)\n- [Dokumentacja Next Intlayer](/pl/doc/environment/nextjs/15)\n\nTe zasoby dostarczają dodatkowych informacji na temat konfiguracji i użycia Intlayer w różnych środowiskach oraz z różnymi frameworkami.\n\n### Using Ordinal Enumeration\n\n\n \n\nTo use this in a React component, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"react\";\nimport { useIntlayer } from \"react-intlayer\";\n\nconst RankingComponent: FC<{ count: number }> = ({ count }) => {\n const { ordinal } = useIntlayer(\"ranking_component\");\n\n // Get the last digit to determine the correct suffix\n const lastDigit = Math.abs(count) % 10;\n\n return (\n
\n

\n {\n ordinal(lastDigit)({ count }) // e.g., \"5th place\" for count=5\n }\n

\n
\n );\n};\n```\n\n
\n \n\nTo use this in Next.js Client Components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\n\"use client\";\n\nimport type { FC } from \"react\";\nimport { useIntlayer } from \"next-intlayer\";\n\nconst RankingComponent: FC<{ count: number }> = ({ count }) => {\n const { ordinal } = useIntlayer(\"ranking_component\");\n const lastDigit = Math.abs(count) % 10;\n\n return (\n
\n

{ordinal(lastDigit)({ count })}

\n
\n );\n};\n\nexport default RankingComponent;\n```\n\n
\n \n\nTo use this in Vue components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:\n\n```vue fileName=\"**/*.vue\"\n\n\n\n```\n\n \n \n\nTo use this in Svelte components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:\n\n```svelte fileName=\"**/*.svelte\"\n\n\n
\n

{$content.ordinal(lastDigit)({ count })}

\n
\n```\n\n
\n \n\nTo use this in Preact components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"preact\";\nimport { useIntlayer } from \"preact-intlayer\";\n\nconst RankingComponent: FC<{ count: number }> = ({ count }) => {\n const { ordinal } = useIntlayer(\"ranking_component\");\n const lastDigit = Math.abs(count) % 10;\n\n return (\n
\n

{ordinal(lastDigit)({ count })}

\n
\n );\n};\n\nexport default RankingComponent;\n```\n\n
\n \n\nTo use this in SolidJS components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { Component } from \"solid-js\";\nimport { useIntlayer } from \"solid-intlayer\";\n\nconst RankingComponent: Component<{ count: number }> = (props) => {\n const { ordinal } = useIntlayer(\"ranking_component\");\n\n return (\n
\n

{ordinal(Math.abs(props.count) % 10)({ count: props.count })}

\n
\n );\n};\n\nexport default RankingComponent;\n```\n\n
\n \n\nTo use this in Angular components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:\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-ranking\",\n template: `\n
\n

{{ content().ordinal(lastDigit())({ count }) }}

\n
\n `,\n})\nexport class RankingComponent {\n @Input() count!: number;\n\n content = useIntlayer(\"ranking_component\");\n\n lastDigit() {\n return Math.abs(this.count) % 10;\n }\n}\n```\n\n
\n \n\nTo use this with `vanilla-intlayer`, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:\n\n```typescript fileName=\"**/*.ts\" codeFormat={[\"typescript\", \"esm\"]}\nimport { installIntlayer, useIntlayer } from \"vanilla-intlayer\";\n\ninstallIntlayer();\n\nconst content = useIntlayer(\"ranking_component\");\nconst lastDigit = Math.abs(5) % 10;\n\ndocument.getElementById(\"ranking\")!.textContent = content.ordinal(lastDigit)({\n count: 5,\n});\n```\n\n \n
\n\n## Combining Enumeration with Insert for Ordinal Numbers\n\n\n \n\nTo use enumeration in a React component, you can leverage the `useIntlayer` hook from the `react-intlayer` package. This hook retrieves the correct content based on the specified ID. Here's an example of how to use it:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"react\";\nimport { useIntlayer } from \"react-intlayer\";\n\nconst CarComponent: FC = () => {\n const { numberOfCar } = useIntlayer(\"car_count\");\n\n return (\n
\n

\n {\n numberOfCar(0) // Output: No cars\n }\n

\n

\n {\n numberOfCar(6) // Output: Some cars\n }\n

\n

\n {\n numberOfCar(20) // Output: Many cars\n }\n

\n

\n {\n numberOfCar(0.01) // Output: Fallback value\n }\n

\n
\n );\n};\n```\n\n
\n \n\nTo use enumeration in Next.js Client Components, retrieve it via the `useIntlayer` hook. 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 CarComponent: FC = () => {\n const { numberOfCar } = useIntlayer(\"car_count\");\n\n return (\n
\n

{numberOfCar(6)}

\n
\n );\n};\n\nexport default CarComponent;\n```\n\n
\n \n\nTo use enumeration in Vue components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```vue fileName=\"**/*.vue\"\n\n\n\n```\n\n \n \n\nTo use enumeration in Svelte components, retrieve it via the `useIntlayer` hook. The store is accessed with `$`. Here's an example:\n\n```svelte fileName=\"**/*.svelte\"\n\n\n
\n

{$content.numberOfCar(6)}

\n
\n```\n\n
\n \n\nTo use enumeration in Preact components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"preact\";\nimport { useIntlayer } from \"preact-intlayer\";\n\nconst CarComponent: FC = () => {\n const { numberOfCar } = useIntlayer(\"car_count\");\n\n return (\n
\n

{numberOfCar(6)}

\n
\n );\n};\n\nexport default CarComponent;\n```\n\n
\n \n\nTo use enumeration in SolidJS components, retrieve it via the `useIntlayer` hook. 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 CarComponent: Component = () => {\n const { numberOfCar } = useIntlayer(\"car_count\");\n\n return (\n
\n

{numberOfCar(6)}

\n
\n );\n};\n\nexport default CarComponent;\n```\n\n
\n \n\nTo use enumeration in Angular components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```typescript fileName=\"app.component.ts\" codeFormat=\"typescript\"\nimport { Component } from \"@angular/core\";\nimport { useIntlayer } from \"angular-intlayer\";\n\n@Component({\n selector: \"app-car\",\n template: `\n
\n

{{ content().numberOfCar(6) }}

\n
\n `,\n})\nexport class CarComponent {\n content = useIntlayer(\"car_count\");\n}\n```\n\n
\n \n\nTo use enumeration with `vanilla-intlayer`, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```typescript fileName=\"**/*.ts\" codeFormat={[\"typescript\", \"esm\"]}\nimport { installIntlayer, useIntlayer } from \"vanilla-intlayer\";\n\ninstallIntlayer();\n\nconst content = useIntlayer(\"car_count\").onChange((newContent) => {\n document.getElementById(\"cars\")!.textContent = newContent.numberOfCar(6);\n});\n\n// Initial render\ndocument.getElementById(\"cars\")!.textContent = content.numberOfCar(6);\n```\n\n \n
\n## Additional Resources\n\nFor more detailed information on configuration and usage, refer to the following resources:\n\n- [Intlayer CLI Documentation](/pl/doc/concept/cli)\n- [React Intlayer Documentation](/pl/doc/environment/create-react-app)\n- [Next Intlayer Documentation](/pl/doc/environment/nextjs/15)\n\nThese resources provide further insights into the setup and usage of Intlayer in different environments and with various frameworks.\n","description":"Odkryj, jak deklarować i używać enumeracji na swojej wielojęzycznej stronie internetowej. Postępuj zgodnie z krokami w tej dokumentacji online, aby skonfigurować swój projekt w kilka minut.","url":"https://intlayer.org/pl/doc/concept/content/enumeration","datePublished":"2025-08-23","dateModified":"2025-08-23","version":"5.5.10","keywords":"Enumeracja, Internacjonalizacja, Dokumentacja, Intlayer, Next.js, JavaScript, React","license":"https://raw.githubusercontent.com/aymericzip/intlayer/refs/heads/main/LICENSE","audience":{"@type":"Audience","audienceType":"Programiści, Menedżerowie treści"}}
    Autor:
    Data utworzenia:2025-08-23Ostatnia aktualizacja:2025-08-23

    Enumeracja / Pluralizacja

    Jak działa enumeracja

    W Intlayer enumeracja jest realizowana za pomocą funkcji enu, która mapuje określone klucze na odpowiadające im treści. Klucze te mogą reprezentować wartości liczbowe, zakresy lub niestandardowe identyfikatory. W przypadku użycia z React Intlayer lub Next Intlayer odpowiednia treść jest automatycznie wybierana na podstawie lokalizacji aplikacji i zdefiniowanych reguł.

    Konfiguracja enumeracji

    Aby skonfigurować enumerację w swoim projekcie Intlayer, musisz utworzyć moduł zawartości, który zawiera definicje enumeracji. Oto przykład prostej enumeracji dla liczby samochodów:

    **/*.content.ts
    import { enu, type Dictionary } from "intlayer";
    
    const carEnumeration = {
      key: "car_count",
      content: {
        numberOfCar: enu({
          "<-1": "Mniej niż minus jeden samochód",
          "-1": "Minus jeden samochód",
          "0": "Brak samochodów",
          "1": "Jeden samochód",
          ">5": "Kilka samochodów",
          ">19": "Wiele samochodów",
          "fallback": "Wartość domyślna", // Opcjonalne
        }),
      },
    } satisfies Dictionary;
    
    export default carEnumeration;

    W tym przykładzie enu mapuje różne warunki na określoną treść. Gdy jest używany w komponencie React, Intlayer może automatycznie wybrać odpowiednią treść na podstawie podanej zmiennej.

    Kolejność deklaracji jest ważna w enumeracjach Intlayer. Pierwsza prawidłowa deklaracja jest tą, która zostanie wybrana. Jeśli wiele warunków ma zastosowanie, upewnij się, że są one poprawnie uporządkowane, aby uniknąć nieoczekiwanego zachowania.
    Jeśli nie zostanie zadeklarowana wartość domyślna (fallback), funkcja zwróci undefined, jeśli żaden klucz nie pasuje.

    Używanie enumeracji z React Intlayer

    To use enumeration in a React component, you can leverage the useIntlayer hook from the react-intlayer package. This hook retrieves the correct content based on the specified ID. Here's an example of how to use it:

    **/*.tsx
    import type { FC } from "react";
    import { useIntlayer } from "react-intlayer";
    
    const CarComponent: FC = () => {
    const { numberOfCar } = useIntlayer("car_count");
    
    return (
      <div>
        <p>
          {
            numberOfCar(0) // Output: No cars
          }
        </p>
        <p>
          {
            numberOfCar(6) // Output: Some cars
          }
        </p>
        <p>
          {
            numberOfCar(20) // Output: Many cars
          }
        </p>
        <p>
          {
            numberOfCar(0.01) // Output: Fallback value
          }
        </p>
      </div>
    );
    };

    Dodatkowe zasoby

    Aby uzyskać bardziej szczegółowe informacje na temat konfiguracji i użytkowania, zapoznaj się z następującymi zasobami:

    Te zasoby dostarczają dodatkowych informacji na temat konfiguracji i użycia Intlayer w różnych środowiskach oraz z różnymi frameworkami.

    Using Ordinal Enumeration

    To use this in a React component, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:

    **/*.tsx
    import type { FC } from "react";
    import { useIntlayer } from "react-intlayer";
    
    const RankingComponent: FC<{ count: number }> = ({ count }) => {
    const { ordinal } = useIntlayer("ranking_component");
    
    // Get the last digit to determine the correct suffix
    const lastDigit = Math.abs(count) % 10;
    
    return (
      <div>
        <p>
          {
            ordinal(lastDigit)({ count }) // e.g., "5th place" for count=5
          }
        </p>
      </div>
    );
    };

    Combining Enumeration with Insert for Ordinal Numbers

    To use enumeration in a React component, you can leverage the useIntlayer hook from the react-intlayer package. This hook retrieves the correct content based on the specified ID. Here's an example of how to use it:

    **/*.tsx
    import type { FC } from "react";
    import { useIntlayer } from "react-intlayer";
    
    const CarComponent: FC = () => {
    const { numberOfCar } = useIntlayer("car_count");
    
    return (
      <div>
        <p>
          {
            numberOfCar(0) // Output: No cars
          }
        </p>
        <p>
          {
            numberOfCar(6) // Output: Some cars
          }
        </p>
        <p>
          {
            numberOfCar(20) // Output: Many cars
          }
        </p>
        <p>
          {
            numberOfCar(0.01) // Output: Fallback value
          }
        </p>
      </div>
    );
    };

    Additional Resources

    For more detailed information on configuration and usage, refer to the following resources:

    These resources provide further insights into the setup and usage of Intlayer in different environments and with various frameworks.