--- createdAt: 2026-06-12 updatedAt: 2026-06-12 title: Динамические Записи description: Используйте поле meta в файлах контента Intlayer для объявления записей, управляемых CMS, получаемых во время выполнения по непрозрачному идентификатору ID, что обеспечивает строгую типизацию динамического контента без перечисления во время сборки. keywords: - Динамические Записи - Динамический Контент - CMS - Контент во Время Выполнения - Intlayer - Интернационализация slugs: - doc - concept - dynamic-records history: - version: 9.0.0 date: 2026-06-12 changes: "Выпуск функции динамического контента" author: aymericzip --- # Динамические Записи **Динамическая запись** (dynamic record) — это файл контента, идентификация которого основана не на последовательном индексе или именованном варианте, а на произвольном наборе пар ключ-значение, объявленных в поле `meta`. Intlayer использует эти поля в качестве селектора во время выполнения, что позволяет адресовать записи CMS, контент конкретного пользователя или любые данные, ключи которых неизвестны во время сборки. ## Объявление динамических записей ```ts fileName="product-copy.abc.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]} 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; ``` ```ts fileName="product-copy.abcd.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]} 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. ```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]} 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

{content.description}

; }; ```
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { useIntlayer } from "next-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

{content.description}

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

{$content.description}

{/if} ```
```tsx fileName="ProductCopy.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { useIntlayer } from "preact-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

{content.description}

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

{content().description}

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

{{ content().description }}

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

${content.description}

`; } ```
### С явным указанием локали ```tsx const content = useIntlayer("product-copy", { id: "prod_abc", userId: "user_123", locale: "ru", }); ``` ### Отсутствие поля meta — ошибка во время компиляции ```ts // Ошибка типа: отсутствует `userId` const content = useIntlayer("product-copy", { id: "prod_abc" }); ``` ## Режим загрузки (loading mode) Динамические записи обычно загружаются отложено. Установите `importMode` для словаря, чтобы настроить это: ```ts contentDeclarationFormat={["typescript", "esm", "commonjs"]} const dictionary = { key: "product-copy", importMode: "fetch", // или "dynamic" meta: { id: "prod_abc", userId: "user_123" }, content: { … }, } satisfies Dictionary; export default dictionary; ``` Подробную информацию о режимах `static`, `dynamic` и `fetch` см. в разделе [оптимизация пакетов](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/bundle_optimization.md). ## Типичные варианты использования - Маркетинговые тексты для отдельных продуктов, управляемые в CMS - Контент конкретного пользователя или учетной записи - Любой контент, получаемый на основе непрозрачного runtime ID