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. Per Locale File
    Creation:2025-04-18Last update:2025-06-29
    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 for per-locale files"
      v7.3.111/29/2025
    2. "Init history"
      v5.5.106/29/2025
    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

    Declaration of Per-Locale Content Declaration in Intlayer

    Intlayer supports two ways to declare multilingual content:

    • Single file with all translations
    • One file per locale (per-locale format)

    This flexibility enables:

    • Easy migration from other i18n tools
    • Support for automated translation workflows
    • Clear organization of translations into separate, locale-specific files

    Per-Locale Format

    This format is useful when:

    • You want to version or override translations independently.
    • You're integrating machine or human translation workflows.

    You can also split translations into individual locale files by specifying the locale field:

    hello-world.es.content.ts
    Copy code

    Copy the code to the clipboard

    import { t, Locales, type Dictionary } from "intlayer";
    
    const helloWorldContent = {
      key: "hello-world",
      locale: Locales.SPANISH, // Important
      content: { multilingualContent: "Título de mi componente" },
    } satisfies Dictionary;
    
    export default helloWorldContent;
    Important: Make sure the locale field is defined. It tells Intlayer which language the file represents.
    Note: In both cases, the content declaration file must follow the naming pattern *.content.{ts,tsx,js,jsx,mjs,cjs,json} to be recognized by Intlayer. The .[locale] suffix is optional and used only as a naming convention.

    Global Configuration for Per-Locale Files

    You can configure the global configuration for per-locale files by adding the following to your intlayer.config.ts file:

    ts
    Copy code

    Copy the code to the clipboard

    import { Locales, type IntlayerConfig } from "intlayer";const config: IntlayerConfig = {  dictionary: {    locale: Locales.ENGLISH,  },};export default config;

    Using this configuration, all per-locale files will be generated with the default locale set to English. It also include generation of .content files using the extract command, and the compiler. (See Compiler or Extract for more information.)

    Single File with Multiple Translations

    This format is ideal for:

    • Quick iteration in code.
    • Seamless integration with the CMS.

    This is the recommended approach for most use cases. It centralizes translations, making it easy to iterate and integrate with the CMS.

    hello-world.content.ts
    Copy code

    Copy the code to the clipboard

    import { t, type Dictionary } from "intlayer";
    
    const helloWorldContent = {
      key: "hello-world",
      content: {
        multilingualContent: t({
          en: "Title of my component",
          es: "Título de mi componente",
        }),
      },
    } satisfies Dictionary;
    
    export default helloWorldContent;
    Recommended: This format is best when using Intlayer's visual editor or managing translations directly in the code.

    Mixing Formats

    You can combine both declaration approaches for the same content key. For example:

    • Declare your base content statically in a file like index.content.ts.
    • Add or override specific translations in separate files such as index.fr.content.ts or index.content.json.

    This setup is especially useful when:

    • You want to define the initial content structure in code.
    • You plan to enrich or complete translations later using the CMS or automated tools.
    bash
    Copy code

    Copy the code to the clipboard

    .└── Components    └── MyComponent        ├── index.content.ts        ├── index.content.json        └── index.ts

    Example

    Here a multilingual content declaration file:

    Components/MyComponent/index.content.ts
    Copy code

    Copy the code to the clipboard

    import { t, type Dictionary } from "intlayer";const helloWorldContent = {  key: "hello-world",  locale: Locales.ENGLISH,  content: {    multilingualContent: "Title of my component",    projectName: "My project",  },} satisfies Dictionary;export default helloWorldContent;
    Components/MyComponent/index.content.json
    Copy code

    Copy the code to the clipboard

    {  "$schema": "https://intlayer.org/schema.json",  "key": "hello-world",  "content": {    "multilingualContent": {      "nodeType": "translation",      "translation": {        "fr": "Titre de mon composant",        "es": "Título de mi componente"      }    }  }}

    Intlayer merges multilingual and per-locale files automatically.

    Components/MyComponent/index.ts
    Copy code

    Copy the code to the clipboard

    import { getIntlayer, Locales } from "intlayer";const intlayer = getIntlayer("hello-world"); // Default locale is ENGLISH, so it will return the ENGLISH contentconsole.log(JSON.stringify(intlayer, null, 2));// Result:// {//  "multilingualContent": "Title of my component",//  "projectName": "My project"// }const intlayer = getIntlayer("hello-world", Locales.SPANISH);console.log(JSON.stringify(intlayer, null, 2));// Result:// {//  "multilingualContent": "Título de mi componente",//  "projectName": "My project"// }const intlayer = getIntlayer("hello-world", Locales.FRENCH);console.log(JSON.stringify(intlayer, null, 2));// Result:// {//  "multilingualContent": "Titre de mon composant",//  "projectName": "My project"// }

    Automatic Translation Generation

    Use the intlayer CLI to auto-fill missing translations based on your preferred services.

    Function Fetching
    Compiler
    Alt+→

    In 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 IntlayerConfig } from "intlayer";const config: IntlayerConfig = {  dictionary: {    locale: Locales.ENGLISH,  },};export default config;
      .└── Components    └── MyComponent        ├── index.content.ts        ├── index.content.json        └── index.ts
      import { t, type Dictionary } from "intlayer";const helloWorldContent = {  key: "hello-world",  locale: Locales.ENGLISH,  content: {    multilingualContent: "Title of my component",    projectName: "My project",  },} satisfies Dictionary;export default helloWorldContent;
      {  "$schema": "https://intlayer.org/schema.json",  "key": "hello-world",  "content": {    "multilingualContent": {      "nodeType": "translation",      "translation": {        "fr": "Titre de mon composant",        "es": "Título de mi componente"      }    }  }}
      import { getIntlayer, Locales } from "intlayer";const intlayer = getIntlayer("hello-world"); // Default locale is ENGLISH, so it will return the ENGLISH contentconsole.log(JSON.stringify(intlayer, null, 2));// Result:// {//  "multilingualContent": "Title of my component",//  "projectName": "My project"// }const intlayer = getIntlayer("hello-world", Locales.SPANISH);console.log(JSON.stringify(intlayer, null, 2));// Result:// {//  "multilingualContent": "Título de mi componente",//  "projectName": "My project"// }const intlayer = getIntlayer("hello-world", Locales.FRENCH);console.log(JSON.stringify(intlayer, null, 2));// Result:// {//  "multilingualContent": "Titre de mon composant",//  "projectName": "My project"// }