Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
This doc is out of date, the base version has been updated on 5 October 2025.
Go to English docVersion History
- "Introduction of testing"v6.0.020/09/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
Testing your content
This guide shows how to automatically verify your dictionaries are complete, catch missing translations before shipping, and test localised UI in your app.
What you can test
- Missing translations: fail CI if any required locales are missing for any dictionary.
- Localised UI rendering: render components with a specific locale provider and assert on visible text/attributes.
- Build-time audits: run a quick audit locally via CLI.
Quick start: audit via CLI
Run the audit from your project root:
Copy the code to the clipboard
Useful flags:
--env-file [path]: load environment variables from a file.-e, --env [name]: select an environment profile.--base-dir [path]: set the app base directory for resolution.--verbose: show verbose logs.--prefix [label]: prefix log lines.
Note: the CLI prints a detailed report but does not exit with a non-zero code on failures. For CI gating, add a unit test (below) that asserts zero missing required locales.
Programmatic test (Vitest/Jest)
Use the Intlayer CLI API to assert there are no missing translations for your required locales.
Copy the code to the clipboard
Jest equivalent:
Copy the code to the clipboard
How it works:
- Intlayer reads your configuration (locales, requiredLocales) and declared dictionaries, then reports:
missingTranslations: per‑key, which locales are missing and from which file.missingLocales: union of all missing locales.missingRequiredLocales: subset limited torequiredLocales(or all locales ifrequiredLocalesis not set).
Testing localised UI (React / Next.js)
Render components under an Intlayer provider and assert on visible content.
React example (Testing Library):
Copy the code to the clipboard
Next.js (App Router) example: use the framework wrapper:
Copy the code to the clipboard
Tips:
- When you need raw string values for attributes (e.g.,
aria-label), access the.valuefield returned byuseIntlayerin React. - Keep dictionaries colocated with components for easier unit testing and cleanup.
Continuous Integration
Add a test that fails the build when required translations are missing.
package.json:
Copy the code to the clipboard
GitHub Actions example:
Copy the code to the clipboard
Optional: run the CLI audit for a human-readable summary alongside tests:
Copy the code to the clipboard
Troubleshooting
- Ensure your Intlayer configuration defines
localesand (optionally)requiredLocales. - If your app uses dynamic or remote dictionaries, run tests in an environment where the dictionaries are available.
- For mixed monorepos, use
--base-dirto point the CLI at the correct application root.