Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Add global configuration"v6.0.020/09/2025
- "Add `{{fileName}}` variable"v6.0.017/09/2025
- "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 EnglishIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
Fill Content Declaration File Translations
Autofill content declaration files in your CI are a way to speed up your development workflow.
Understanding the behaviour
The fill command includes two modes:
- Complete: Automatically fill all missing content for each locale and edit the current file, or another file if specified. That is, complete mode will skip the translation of existing content, if already translated.
- Review: Automatically fill all content for each locale and generate for a specific file, or another file if specified.
The fill command will process all your locale content declaration files. That is, it will not process your remote content from the CMS. The CMS includes its own translations management.
If you use plugins such as @intlayer/sync-json-plugin, Intlayer will transform the JSON files into locale content declaration files. That is, they will be processed by the fill command.
The new generated files include a filled instruction as dictionary metadata. This instruction will be used by Intlayer to know if the file has been autofilled or not, and skip this file from being translated again if present.
Intlayer will also consider the following instruction for autofill:
- From your
.content.{ts|js|json}→fillinstruction - From your configuration file
.intlayer.config.ts→dictionary.fillinstruction - Will be set to
trueby default otherwise
For per-locale content declaration files, the true instruction will be replaced by ./{{fileName}}.fill.content.json. This is because a per-locale content declaration file cannot receive additional localised content. So it will generate a new file to not overwrite the existing file.
Default Behavior
By default, fill is set to true globally, which means Intlayer will automatically fill all content files and edit the file itself. This behaviour can be customised in several ways:
Global Configuration Options
fill: true(default) - Automatically fill all locales and edit the current filefill: false- Disable auto-fill for this content filefill: "./relative/path/to/file"- Create/update the specified file without editing the current one by pointing to a relative path resolved based on the location of the current filefill: "/absolute/path/to/file"- Create/update the specified file without editing the current one by pointing to a relative path resolved based on the location of base directory (fieldbaseDirin the configuration file.intlayer.config.ts)fill: "C:\absolute\path\to\file"- Create/update the specified file without editing the current one by pointing to an absolute path resolved based on your operating systemfill: { [key in Locales]?: string }- Create/update the specified file for each locale
v7 Behaviour Changes
In v7, the fill command behaviour has been updated:
fill: true- Rewrites the current file with filled content for all localesfill: "path/to/file"- Fills the specified file without modifying the current filefill: false- Disables auto-fill completely
When using a path option to write to another file, the fill mechanism works through a master-slave relationship between content declaration files. The main (master) file serves as the source of truth, and when it's updated, Intlayer will automatically apply those changes to the derived (filled) declaration files specified by the path.
Per-Locale Customisation
You can also customise the behaviour for each locale by using an object:
Copy the code to the clipboard
This allows you to have different fill behaviours for different locales within the same project.
Copy the code to the clipboard
Here is a per-locale content declaration file using the fill instruction.
Then, when you run the following command:
Copy the code to the clipboard
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.
Copy the code to the clipboard
Afterwards, both declaration files will be merged into a single dictionary, accessible using the standard useIntlayer("example") hook (react) / composable (vue).
Global Configuration
You can configure the global auto fill configuration in the intlayer.config.ts file.
Copy the code to the clipboard
You can still fine‑tune per dictionary using the fill field in content files. Intlayer will first consider the per dictionary configuration and then fallback to the global configuration.
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.
Copy the code to the clipboard
This will generate the file at:
Copy the code to the clipboard
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.
Copy the code to the clipboard
This will generate the file at:
Copy the code to the clipboard
Autogenerate Per-Locale Content Declaration Files
The autoFill field also supports the generation of per-locale content declaration files.
Copy the code to the clipboard
This will generate two separate files:
src/components/example/example.fr.content.jsonsrc/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.
Copy the code to the clipboard
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)
Copy the code to the clipboard
This will generate:
/messages/fr/example.content.json/messages/es/example.content.json
Copy the code to the clipboard
This will generate:
./index.content.json./index.content.json