--- createdAt: 2026-06-12 updatedAt: 2026-06-12 title: Kolekcje description: Użyj pola metadanych item w plikach zawartości Intlayer, aby budować uporządkowane kolekcje zlokalizowanych elementów wybieranych według indeksu w czasie wykonywania. keywords: - Kolekcje - Lista Zawartości - Zawartość Dynamiczna - Intlayer - Umiędzynarodowienie slugs: - doc - concept - collections history: - version: 9.0.0 date: 2026-06-12 changes: "Wydanie funkcji słowników kolekcji" author: aymericzip --- # Kolekcje **Kolekcja** (Collection) to zestaw plików zawartości, które współdzielą ten sam klucz słownika (`key`), ale każdy deklaruje inny indeks elementu (`item`). Intlayer scala je w jedną uporządkowaną listę podczas budowania projektu. ## Deklarowanie elementów kolekcji Każdy plik reprezentuje jeden element. Pole `item` to jego pozycja na liście (indeksowanie od 1). ```ts fileName="faq.1.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { t, type Dictionary } from "intlayer"; const dictionary = { key: "faq", item: 1, content: { question: t({ en: "What is Intlayer?", fr: "Qu'est-ce qu'Intlayer ?" }), answer: t({ en: "An i18n toolkit.", fr: "Une boîte à outils i18n." }), }, } satisfies Dictionary; export default dictionary; ``` ```ts fileName="faq.2.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { t, type Dictionary } from "intlayer"; const dictionary = { key: "faq", item: 2, content: { question: t({ en: "Is it free?", fr: "Est-ce gratuit ?" }), answer: t({ en: "Yes, open-source.", fr: "Oui, open-source." }), }, } satisfies Dictionary; export default dictionary; ``` ## Używanie kolekcji ### Wszystkie elementy ```tsx fileName="FAQ.tsx" import { useIntlayer } from "react-intlayer"; export const FAQ = () => { const items = useIntlayer("faq"); // { question: string; answer: string }[] return ( ); }; ``` ```tsx fileName="FAQ.tsx" import { useIntlayer } from "next-intlayer"; export const FAQ = () => { const items = useIntlayer("faq"); // { question: string; answer: string }[] return ( ); }; ``` ```vue fileName="FAQ.vue" ``` ```svelte fileName="FAQ.svelte" ``` ```tsx fileName="FAQ.tsx" import { useIntlayer } from "preact-intlayer"; export const FAQ = () => { const items = useIntlayer("faq"); // { question: string; answer: string }[] return ( ); }; ``` ```tsx fileName="FAQ.tsx" import { useIntlayer } from "solid-intlayer"; import { For } from "solid-js"; export const FAQ = () => { const items = useIntlayer("faq"); // { question: string; answer: string }[] return ( ); }; ``` ```typescript fileName="faq.component.ts" import { Component } from "@angular/core"; import { useIntlayer } from "angular-intlayer"; @Component({ selector: "app-faq", template: ` `, }) export class FAQComponent { items = useIntlayer("faq"); } ``` ```javascript fileName="faq.js" import { useIntlayer } from "vanilla-intlayer"; const faq = useIntlayer("faq"); faq.forEach((item) => { console.log(item.question); console.log(item.answer); }); ``` ### Pojedynczy element według indeksu ```tsx const faq2 = useIntlayer("faq", { item: 2 }); // → { question: string; answer: string } ``` ### Pojedynczy element z wyraźnym wskazaniem lokalizacji ```tsx const faq2Pl = useIntlayer("faq", { item: 2, locale: "pl" }); ``` ## Typowe przypadki użycia - Listy FAQ (najczęściej zadawane pytania) - Plany cenowe / cenniki - Slajdy w karuzelach i sliderach - Instrukcje krok po kroku