\n\n \n ```\n\n \n \n ```svelte fileName=\"FAQ.svelte\"\n \n\n \n ```\n\n \n \n ```tsx fileName=\"FAQ.tsx\"\n import { useIntlayer } from \"preact-intlayer\";\n\n export const FAQ = () => {\n const items = useIntlayer(\"faq\"); // { question: string; answer: string }[]\n\n return (\n \n );\n };\n ```\n\n \n \n ```tsx fileName=\"FAQ.tsx\"\n import { useIntlayer } from \"solid-intlayer\";\n import { For } from \"solid-js\";\n\n export const FAQ = () => {\n const items = useIntlayer(\"faq\"); // { question: string; answer: string }[]\n\n return (\n \n );\n };\n ```\n\n \n \n ```typescript fileName=\"faq.component.ts\"\n import { Component } from \"@angular/core\";\n import { useIntlayer } from \"angular-intlayer\";\n\n @Component({\n selector: \"app-faq\",\n template: `\n \n `,\n })\n export class FAQComponent {\n items = useIntlayer(\"faq\");\n }\n ```\n\n \n \n ```javascript fileName=\"faq.js\"\n import { useIntlayer } from \"vanilla-intlayer\";\n\n const faq = useIntlayer(\"faq\");\n\n faq.forEach((item) => {\n console.log(item.question);\n console.log(item.answer);\n });\n ```\n\n \n\n\n### Mục đơn theo chỉ mục (index)\n\n```tsx\nconst faq2 = useIntlayer(\"faq\", { item: 2 });\n// → { question: string; answer: string }\n```\n\n### Mục đơn với ngôn ngữ (locale) rõ ràng\n\n```tsx\nconst faq2Vi = useIntlayer(\"faq\", { item: 2, locale: \"vi\" });\n```\n\n## Các trường hợp sử dụng điển hình\n\n- Danh sách Câu hỏi thường gặp (FAQ)\n- Các gói định giá\n- Các slide trình chiếu / carousel\n- Hướng dẫn từng bước\n","description":"Sử dụng trường siêu dữ liệu item trong các tệp nội dung Intlayer để xây dựng các bộ sưu tập có thứ tự gồm các mục được bản địa hóa có thể chọn theo chỉ mục ở runtime.","url":"https://intlayer.org/vi/doc/concept/collections","datePublished":"2026-06-12","dateModified":"2026-06-12","version":"9.0.0","keywords":"Bộ Sưu Tập, Danh Sách Nội Dung, Nội Dung Động, Intlayer, Quốc tế hóa","license":"https://raw.githubusercontent.com/aymericzip/intlayer/refs/heads/main/LICENSE","audience":{"@type":"Audience","audienceType":"Nhà phát triển (Developers), Quản trị nội dung (Content Managers)"}}
    Tác giả:
    Ngày tạo:2026-06-12Cập nhật lần cuối:2026-06-12

    Bộ Sưu Tập

    Một bộ sưu tập (collection) là một tập hợp các tệp nội dung chia sẻ cùng một khóa từ điển (key) nhưng mỗi tệp khai báo một chỉ mục mục (item) khác nhau. Intlayer hợp nhất chúng thành một danh sách có thứ tự duy nhất tại thời điểm build.

    Khai báo các mục trong bộ sưu tập

    Mỗi tệp đại diện cho một mục. Trường item là vị trí của nó trong danh sách (bắt đầu bằng 1).

    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;

    Sử dụng bộ sưu tập

    Tất cả các mục

    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>  );};

    Mục đơn theo chỉ mục (index)

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

    Mục đơn với ngôn ngữ (locale) rõ ràng

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

    Các trường hợp sử dụng điển hình

    • Danh sách Câu hỏi thường gặp (FAQ)
    • Các gói định giá
    • Các slide trình chiếu / carousel
    • Hướng dẫn từng bước