Yazar:
    Oluşturma:2026-06-12Son güncelleme:2026-06-12

    Koleksiyonlar

    Bir koleksiyon (collection), aynı sözlük anahtarını (key) paylaşan ancak her biri farklı bir item dizini bildiren içerik dosyaları kümesidir. Intlayer, derleme zamanında bunları tek bir sıralı listede birleştirir.

    Koleksiyon öğelerini bildirme

    Her dosya bir öğeyi temsil eder. item alanı, öğenin listedeki konumudur (1 tabanlıdır).

    faq.1.content.ts
    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;
    faq.2.content.ts
    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;

    Bir koleksiyonu tüketme

    Tüm öğeler

    FAQ.tsx
    import { useIntlayer } from "react-intlayer";export const FAQ = () => {  const items = useIntlayer("faq"); // { question: string; answer: string }[]  return (    <ul>      {items.map((item, index) => (        <li key={index}>          <strong>{item.question}</strong>          <p>{item.answer}</p>        </li>      ))}    </ul>  );};

    Dizine göre tek öğe

    tsx
    const faq2 = useIntlayer("faq", { item: 2 });// → { question: string; answer: string }

    Belirli dil seçeneği ile tek öğe

    tsx
    const faq2Tr = useIntlayer("faq", { item: 2, locale: "tr" });

    Tipik kullanım senaryoları

    • SSS listeleri
    • Fiyatlandırma seviyeleri
    • Karusel / slayt gösterisi slaytları
    • Adım adım talimatlar