\n\n \n ```\n\n \n \n ```svelte fileName=\"ProductCopy.svelte\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\n \n\n {#if $content}\n

{$content.description}

\n {/if}\n ```\n\n
\n \n ```tsx fileName=\"ProductCopy.tsx\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\n import { useIntlayer } from \"preact-intlayer\";\n\n export const ProductCopy = ({\n productId,\n userId,\n }: {\n productId: string;\n userId: string;\n }) => {\n const content = useIntlayer(\"product-copy\", { id: productId, userId });\n // TypeScript гарантує, що надано як `id`, так і `userId`.\n\n if (!content) return null;\n\n return

{content.description}

;\n };\n ```\n\n
\n \n ```tsx fileName=\"ProductCopy.tsx\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\n import { useIntlayer } from \"solid-intlayer\";\n\n export const ProductCopy = (props: {\n productId: string;\n userId: string;\n }) => {\n const content = useIntlayer(\"product-copy\", { id: props.productId, userId: props.userId });\n // TypeScript гарантує, что надано як `id`, так і `userId`.\n\n return (\n <>\n {content() &&

{content().description}

}\n \n );\n };\n ```\n\n
\n \n ```typescript fileName=\"product-copy.component.ts\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\n import { Component, Input, OnInit } from \"@angular/core\";\n import { useIntlayer } from \"angular-intlayer\";\n\n @Component({\n selector: \"app-product-copy\",\n template: `\n @if (content()) {\n

{{ content().description }}

\n }\n `,\n })\n export class ProductCopyComponent implements OnInit {\n @Input() productId!: string;\n @Input() userId!: string;\n\n content: any;\n\n ngOnInit() {\n this.content = useIntlayer(\"product-copy\", { id: this.productId, userId: this.userId });\n }\n }\n ```\n\n
\n \n ```javascript fileName=\"product-copy.js\"\n import { useIntlayer } from \"vanilla-intlayer\";\n\n const content = useIntlayer(\"product-copy\", {\n id: \"prod_abcd\",\n userId: \"user_123\"\n });\n\n if (content) {\n document.body.innerHTML = `

${content.description}

`;\n }\n ```\n\n
\n\n\n### З явною локаллю\n\n```tsx\nconst content = useIntlayer(\"product-copy\", {\n id: \"prod_abc\",\n userId: \"user_123\",\n locale: \"uk\",\n});\n```\n\n### Відсутність поля meta — помилка під час компіляції\n\n```ts\n// Помилка типу: відсутній `userId`\nconst content = useIntlayer(\"product-copy\", { id: \"prod_abc\" });\n```\n\n## Режим завантаження (loading mode)\n\nДинамічні записи зазвичай завантажуються відкладено. Установіць `importMode` для словника, щоб налаштувати це:\n\n```ts contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\nconst dictionary = {\n key: \"product-copy\",\n importMode: \"fetch\", // або \"dynamic\"\n meta: { id: \"prod_abc\", userId: \"user_123\" },\n content: { … },\n} satisfies Dictionary;\n\nexport default dictionary;\n```\n\nДетальніше про режими `static`, `dynamic` та `fetch` див. у розділі [оптимізація пакетів](/uk/doc/concept/bundle-optimization).\n\n## Типові варіанти використання\n\n- Маркетингові тексти для окремих продуктів, керовані в CMS\n- Вміст конкретного користувача або облікового запису\n- Будь-який вміст, що отримується на основі непрозорого runtime ID\n","description":"Використовуйте поле meta у файлах вмісту Intlayer для оголошення записів, керованих CMS, що отримуються під час виконання за непрозорим ідентифікатором ID, що дозволяє створювати строго типізований динамічний вміст без перерахування під час складання.","url":"https://intlayer.org/uk/doc/concept/dynamic-records","datePublished":"2026-06-12","dateModified":"2026-06-12","version":"9.0.0","keywords":"Динамічні Записи, Динамічний Вміст, CMS, Вміст під Час Виконання, Intlayer, Інтернаціоналізація","license":"https://raw.githubusercontent.com/aymericzip/intlayer/refs/heads/main/LICENSE","audience":{"@type":"Audience","audienceType":"Розробники, менеджери контенту"}}
    Автор:
    Дата створення:2026-06-12Останнє оновлення:2026-06-12

    Динамічні Записи

    Динамічний запис (dynamic record) — це файл вмісту, ідентифікація якого базується не на послідовному індексі чи іменованому варіанті, а на довільному наборі пар ключ-значення, оголошених у полі meta. Intlayer використовує ці поля як селектор під час виконання, що дозволяє адресувати записи CMS, вміст конкретного користувача або будь-які дані, ключі яких невідомі під час збирання проекту.

    Оголошення динамічних записів

    product-copy.abc.content.ts
    import { t, type Dictionary } from "intlayer";
    
    const dictionary = {
      key: "product-copy",
      meta: {
        id: "prod_abc",
        userId: "user_123",
      },
      content: {
        name: t({ en: "Widget Pro", fr: "Widget Pro" }),
        description: t({ en: "The best widget.", fr: "Le meilleur widget." }),
      },
    } satisfies Dictionary;
    
    export default dictionary;
    product-copy.abcd.content.ts
    import { t, type Dictionary } from "intlayer";
    
    const dictionary = {
      key: "product-copy",
      meta: {
        id: "prod_abcd",
        userId: "user_123",
      },
      content: {
        name: t({ en: "Widget Lite", fr: "Widget Lite" }),
        description: t({ en: "A lighter option.", fr: "Une option plus légère." }),
      },
    } satisfies Dictionary;
    
    export default dictionary;

    Використання динамічних записів

    Усі поля meta є обов'язковими в селекторі. Опущення будь-якого поля повертає null і є помилкою TypeScript.

    ProductCopy.tsx
    import { useIntlayer } from "react-intlayer";
    
    export const ProductCopy = ({
      productId,
      userId,
    }: {
      productId: string;
      userId: string;
    }) => {
      const content = useIntlayer("product-copy", { id: productId, userId });
      // TypeScript гарантує, що надано як `id`, так і `userId`.
    
      if (!content) return null;
    
      return <p>{content.description}</p>;
    };

    З явною локаллю

    tsx
    const content = useIntlayer("product-copy", {  id: "prod_abc",  userId: "user_123",  locale: "uk",});

    Відсутність поля meta — помилка під час компіляції

    ts
    // Помилка типу: відсутній `userId`const content = useIntlayer("product-copy", { id: "prod_abc" });

    Режим завантаження (loading mode)

    Динамічні записи зазвичай завантажуються відкладено. Установіць importMode для словника, щоб налаштувати це:

    ts
    const dictionary = {
      key: "product-copy",
      importMode: "fetch", // або "dynamic"
      meta: { id: "prod_abc", userId: "user_123" },
      content: { … },
    } satisfies Dictionary;
    
    export default dictionary;

    Детальніше про режими static, dynamic та fetch див. у розділі оптимізація пакетів.

    Типові варіанти використання

    • Маркетингові тексти для окремих продуктів, керовані в CMS
    • Вміст конкретного користувача або облікового запису
    • Будь-який вміст, що отримується на основі непрозорого runtime ID