\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: \"ja\",\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動的レコードは通常、遅延読み込み(lazy loading)されます。制御するには、ディクショナリで `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` モードの詳細については、[バンドルの最適化](/ja/doc/concept/bundle-optimization) を参照してください。\n\n## 一般的なユースケース\n\n- CMSで管理される商品ごとのマーケティングコピー\n- ユーザー固有またはアカウント固有のコンテンツ\n- 不透明なランタイムIDをキーとするあらゆるコンテンツ\n","description":"Intlayerのコンテンツファイルでmetaフィールドを使用して、不透明なIDでランタイムに取得されるCMS管理レコードを宣言します。これにより、ビルド時に列挙することなく、厳密に型指定された動的コンテンツを実現します。","url":"https://intlayer.org/ja/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: "ja",});

    metaフィールドの不足 — コンパイルエラー

    ts
    // 型エラー: `userId` が不足していますconst content = useIntlayer("product-copy", { id: "prod_abc" });

    読み込みモード (loading mode)

    動的レコードは通常、遅延読み込み(lazy loading)されます。制御するには、ディクショナリで importMode を設定します:

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

    staticdynamicfetch モードの詳細については、バンドルの最適化 を参照してください。

    一般的なユースケース

    • CMSで管理される商品ごとのマーケティングコピー
    • ユーザー固有またはアカウント固有のコンテンツ
    • 不透明なランタイムIDをキーとするあらゆるコンテンツ