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. CLI
    4. Doc Translate
    Creation:2024-08-11Last update:2025-11-22
    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

    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

    Translate Document

    The doc translate command automatically translates documentation files from a base locale to target locales using AI translation services.

    Key Points:

    • Split large markdown files into chunks to stay within the AI model's context window limits.
    • Retry translation if the output format is incorrect.
    • Incorporates application and file-specific context for improved translation accuracy.
    • Preserves existing translations by not overwriting them.
    • Processes files, chunks, and locales in parallel using a queue system to increase speed.
    bash
    Copy code

    Copy the code to the clipboard

    npx intlayer doc translate

    Arguments:

    File list options:

    • --doc-pattern [docPattern...]: Glob patterns to match documentation files to translate.

      Example: npx intlayer doc translate --doc-pattern "docs/**/*.md" "src/**/*.mdx"
    • --excluded-glob-pattern [excludedGlobPattern...]: Glob patterns to exclude from translation.

      Example: npx intlayer doc translate --excluded-glob-pattern "docs/internal/**"
    • --skip-if-modified-before [skipIfModifiedBefore]: Skip the file if it has been modified before the given time.

      • Can be an absolute time as "2025-12-05" (string or Date)
      • Can be a relative time in ms 1 * 60 * 60 * 1000 (1 hour)
      • This option check update time of the file using the fs.stat method. So it could be impacted by Git or other tools that modify the file.
      Example: npx intlayer doc translate --skip-if-modified-before "2025-12-05"
    • --skip-if-modified-after [skipIfModifiedAfter]: Skip the file if it has been modified within the given time.

      • Can be an absolute time as "2025-12-05" (string or Date)
      • Can be a relative time in ms 1 * 60 * 60 * 1000 (1 hour)
      • This option check update time of the file using the fs.stat method. So it could be impacted by Git or other tools that modify the file.
      Example: npx intlayer doc translate --skip-if-modified-after "2025-12-05"
    • --skip-if-exists: Skip the file if it already exists.

      Example: npx intlayer doc translate --skip-if-exists

    Entry output options:

    • --locales [locales...]: Target locales to translate documentation to.

      Example: npx intlayer doc translate --locales fr es de
    • --base-locale [baseLocale]: Source locale to translate from.

      Example: npx intlayer doc translate --base-locale en

    File processing options:

    • --nb-simultaneous-file-processed [nbSimultaneousFileProcessed]: Number of files to process simultaneously for translation.

      Example: npx intlayer doc translate --nb-simultaneous-file-processed 5

    AI options:

    • --model [model]: The AI model to use for translation (e.g., gpt-3.5-turbo).
    • --provider [provider]: The AI provider to use for translation.
    • --temperature [temperature]: Temperature setting for the AI model.
    • --api-key [apiKey]: Provide your own API key for the AI service.
    • --application-context [applicationContext]: Provide additional context for the AI translation.
    • --data-serialization [dataSerialization]: The data serialization format to use for the AI features of Intlayer. Options: json (standard, reliable), toon (fewer tokens, less consistent).
    • --custom-prompt [prompt]: Customize the base prompt used for translation. (Note: For most use cases, the --custom-instructions option is recommended instead as it provides better control over translation behavior.)

      Example: npx intlayer doc translate --model deepseek-chat --provider deepseek --temperature 0.5 --api-key sk-1234567890 --application-context "My application is a cat store"

    Environment variables options:

    • --env: Specify the environment (e.g., development, production).
    • --env-file [envFile]: Provide a custom environment file to load variables from.
    • --base-dir: Specify the base directory for the project.
    • --no-cache: Disable the cache.

      Example: npx intlayer doc translate --base-dir ./docs --env-file .env.production.local

    Log options:

    • --verbose: Enable verbose logging for debugging. (default to true using CLI)

      Example: npx intlayer doc translate --verbose

    Custom instructions options:

    • --custom-instructions [customInstructions]: Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.

      • Can be an absolute time as "2025-12-05" (string or Date)
      • Can be a relative time in ms 1 * 60 * 60 * 1000 (1 hour)
      • This option check update time of the file using the fs.stat method. So it could be impacted by Git or other tools that modify the file.
      Example: npx intlayer doc translate --custom-instructions "Avoid translating urls, and keep the markdown format"
      Example: npx intlayer doc translate --custom-instructions "$(cat ./instructions.md)"

    Git options:

    • --git-diff: Only run on dictionaries that includes changes from base (default origin/main) to current branch (default: HEAD).
    • --git-diff-base: Specify the base reference for git diff (default origin/main).
    • --git-diff-current: Specify the current reference for git diff (default: HEAD).
    • --uncommitted: Include uncommitted changes.
    • --unpushed: Include unpushed changes.
    • --untracked: Include untracked files.

      Example: npx intlayer doc translate --git-diff --git-diff-base origin/main --git-diff-current HEAD
      Example: npx intlayer doc translate --uncommitted --unpushed --untracked

    Note that the output file path will be determined by replacing the following patterns

    • /{{baseLocale}}/ by /{{locale}}/ (Unix)
    • {{baseLocale}}` by {{locale}}` (Windows)
    • _{{baseLocale}}. by _{{locale}}.
    • {{baseLocale}}_ by {{locale}}_
    • .{{baseLocaleName}}. by .{{localeName}}.

    If the pattern is not found, the output file will add the .{{locale}} at the extensions of the file. ./my/file.md will be translated to ./my/file.fr.md for the French locale.

    Doc Review
    SDK
    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.

      npx intlayer doc translate