HomeSandboxShowcaseAppDocBlog
    • EnglishEnglish
      EN
    • русскийRussian
      RU
    • 日本語Japanese
      JA
    • françaisFrench
      FR
    • 한국어Korean
      KO
    • 中文Chinese
      ZH
    • españolSpanish
      ES
    • DeutschGerman
      DE
    • العربيةArabic
      AR
    • italianoItalian
      IT
    • British EnglishBritish English
      EN-GB
    • portuguêsPortuguese
      PT
    • हिन्दीHindi
      HI
    • TürkçeTurkish
      TR
    • polskiPolish
      PL
    • IndonesiaIndonesian
      ID
    • Tiếng ViệtVietnamese
      VI
    • українськаUkrainian
      UK
    /
    Filter docs by framework
    Alt+←
    Why Intlayer ?
    Get Started
    Concept
    • How Intlayer Works
    • Configuration
    • TestFillBuildWatchExtractLoginPushPullConfigurationListVersionEditorLiveDebugDoc ReviewDoc TranslateSDK
    • Visual Editor
    • CMS
    • CI/CD Integration
    • TranslationPluralEnumerationConditionGenderInsertionFileNestingMarkdownHTMLFunction Fetching
    • Per Locale File
    • Compiler
    • Auto Fill
    • Testing
    • Bundle Optimization
    Environment
    • Next.js 14 and App Router
      Next.js 15
      Next.js no locale path
      Next.js and Page Router
      Compiler
    • Tanstack Start Solid
    • Astro and React
      Astro and Svelte
      Astro and Vue
      Astro and Solid
      Astro and Preact
      Astro and Lit
      Astro and Vanilla JS
    • React Router v7
      React Router v7 (fs-routes)
      Compiler
    • Nuxt and Vue
    • Vite and Solid
    • SvelteKit
    • Vite and Preact
    • Vite and Vanilla JS
    • Vite and Lit
    • Angular 19 (Webpack)
      Analog
    • React CRA
    • React Native and Expo
    • Express.js
      NestJS
      Fastify
      Hono
      Adonis
    • Lynx and React
    Plugins
    • JSON
    • gettext (.po)
    VS Code Extension
    Agent
    • MCP Server
    • Agent skills
    Releases
    • v8
    • v7
    • v6
    Benchmark
    • Next.js
    • TanStack
    • Vue
    • Solid
    • Svelte
    Blog
    Ask a question
    1. Documentation
    2. Concept
    3. Auto Fill
    Creation:2025-03-13Last update:2025-09-20
    Reference this doc to your favorite AI assistant
    ChatGPT
    Claude
    DeepSeek
    Google AI mode
    Gemini
    Perplexity
    Mistral
    Grok

    Ask your question and get a summary of the document by referencing this page and the AI provider of your choice

    Version History

    1. "Add global configuration"
      v6.0.020/09/2025
    2. "Add `{{fileName}}` variable"
      v6.0.017/09/2025
    3. "Initialise history"
      v5.5.1029/06/2025

    The content of this page was translated using an AI.

    See the last version of the original content in English
    Edit this doc

    If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.

    GitHub link to the documentation
    Copy

    Copy doc Markdown to clipboard

    Autofill Content Declaration File Translations

    Autofill content declaration files are a way to speed up your development workflow.

    The autofill mechanism works through a master-slave relationship between content declaration files. When the main (master) file is updated, Intlayer will automatically apply those changes to the derived (autofilled) declaration files.

    src/components/example/example.content.ts
    Copy code

    Copy the code to the clipboard

    import { Locales, type Dictionary } from "intlayer";const exampleContent = {  key: "example",  locale: Locales.ENGLISH,  autoFill: "./example.content.json",  content: {    contentExample: "This is an example of content",  },} satisfies Dictionary;export default exampleContent;

    Here is a per-locale content declaration file using the autoFill instruction.

    Then, when you run the following command:

    bash
    Copy code

    Copy the code to the clipboard

    npx intlayer fill --file 'src/components/example/example.content.ts'

    Intlayer will automatically generate the derived declaration file at src/components/example/example.content.json, filling in all locales not already declared in the main file.

    src/components/example/example.content.json
    Copy code

    Copy the code to the clipboard

    {  "key": "example",  "content": {    "contentExample": {      "nodeType": "translation",      "translation": {        "fr": "Ceci est un exemple de contenu",        "es": "Este es un exemple de contenu",      },    },  },}

    Afterwards, both declaration files will be merged into a single dictionary, accessible using the standard useIntlayer("example") hook (React) / composable (Vue).

    Autofilled File Format

    The recommended format for autofilled declaration files is JSON, which helps to avoid formatting constraints. However, Intlayer also supports .ts, .js, .mjs, .cjs, and other formats.

    src/components/example/example.content.ts
    Copy code

    Copy the code to the clipboard

    const exampleContent = {  key: "example",  autoFill: "./example.filled.content.ts",  content: {    // Your content  },};

    This will generate the file at:

    plaintext
    Copy code

    Copy the code to the clipboard

    src/components/example/example.filled.content.ts

    The generation of .js, .ts, and similar files works as follows:

    • If the file already exists, Intlayer will parse it using the AST (Abstract Syntax Tree) to locate each field and insert any missing translations.
    • If the file does not exist, Intlayer will generate it using the default content declaration file template.

    Absolute Paths

    The autoFill field also supports absolute paths.

    src/components/example/example.content.ts
    Copy code

    Copy the code to the clipboard

    const exampleContent = {  key: "example",  autoFill: "/messages/example.content.json",  content: {    // Your content  },};

    This will generate the file at:

    plaintext
    Copy code

    Copy the code to the clipboard

    /messages/example.content.json

    Autogenerate Per-Locale Content Declaration Files

    The autoFill field also supports the generation of per-locale content declaration files.

    src/components/example/example.content.ts
    Copy code

    Copy the code to the clipboard

    const exampleContent = {  key: "example",  autoFill: {    fr: "./example.fr.content.json",    es: "./example.es.content.json",  },  content: {    // Your content  },};

    This will generate two separate files:

    • src/components/example/example.fr.content.json
    • src/components/example/example.es.content.json
    In this case, if the object does not contain all locales, Intlayer skips the generation of the remaining locales.

    Filter Specific Locale Autofill

    Using an object for the autoFill field allows you to apply filters and generate only specific locale files.

    src/components/example/example.content.ts
    Copy code

    Copy the code to the clipboard

    const exampleContent = {  key: "example",  autoFill: {    fr: "./example.fr.content.json",  },  content: {    // Your content  },};

    This will only generate the French translation file.

    Path Variables

    You can use variables inside the autoFill path to dynamically resolve the target paths for the generated files.

    Available variables:

    • {{locale}} – Locale code (e.g. fr, es)
    • {{fileName}} – File name (e.g. index)
    • {{key}} – Dictionary key (e.g. example)
    src/components/example/index.content.ts
    Copy code

    Copy the code to the clipboard

    const exampleContent = {  key: "example",  autoFill: "/messages/{{locale}}/{{key}}.content.json",  content: {    // Your content  },};

    This will generate:

    • /messages/fr/example.content.json
    • /messages/es/example.content.json
    src/components/example/index.content.ts
    Copy code

    Copy the code to the clipboard

    const exampleContent = {  key: "example",  autoFill: "./{{fileName}}.content.json",  content: {    // Your content  },};

    This will generate:

    • ./index.content.json
    • ./index.content.json
    Compiler
    Testing
    Alt+→

    On this page

      Discussions are anonymous and regularly reviewed to address common issues. Feel free to share feature ideas, feedback on the documentation, or anything related to Intlayer, we use this input to shape our roadmap and improve the product.

      import { Locales, type Dictionary } from "intlayer";const exampleContent = {  key: "example",  locale: Locales.ENGLISH,  autoFill: "./example.content.json",  content: {    contentExample: "This is an example of content",  },} satisfies Dictionary;export default exampleContent;
      npx intlayer fill --file 'src/components/example/example.content.ts'
      {  "key": "example",  "content": {    "contentExample": {      "nodeType": "translation",      "translation": {        "fr": "Ceci est un exemple de contenu",        "es": "Este es un exemple de contenu",      },    },  },}
      const exampleContent = {  key: "example",  autoFill: "./example.filled.content.ts",  content: {    // Your content  },};
      src/components/example/example.filled.content.ts
      const exampleContent = {  key: "example",  autoFill: "/messages/example.content.json",  content: {    // Your content  },};
      /messages/example.content.json
      const exampleContent = {  key: "example",  autoFill: {    fr: "./example.fr.content.json",    es: "./example.es.content.json",  },  content: {    // Your content  },};
      const exampleContent = {  key: "example",  autoFill: {    fr: "./example.fr.content.json",  },  content: {    // Your content  },};
      const exampleContent = {  key: "example",  autoFill: "/messages/{{locale}}/{{key}}.content.json",  content: {    // Your content  },};
      const exampleContent = {  key: "example",  autoFill: "./{{fileName}}.content.json",  content: {    // Your content  },};