Linting messages
To ensure quality and completeness of your messages, you can lint them with @eloqnt/cli.
This tool is purpose-built for next-intl, and uses AST-level analysis to catch common issues like missing translations, inconsistent ICU arguments, and more.
Getting started
Install @eloqnt/cli:
npm install @eloqnt/cli --save-devAdd .eloqnt/config.ts:
import {defineConfig} from '@eloqnt/cli';
export default defineConfig({
srcPath: './src',
messages: {
path: './messages',
locales: 'infer',
sourceLocale: 'en',
format: 'json'
}
});See configuration in the @eloqnt/cli docs.
Run the lint command:
npx eloqnt lintExample output:
messages/de.json
│
│ "XOBPYD": "1.000 Teams sind bereits live"
│ ─┬─────────────────────────────
│ ╰─ Missing ICU argument: {count} (inconsistent-args)
│
│ "mCBO12": "Sign up today"
│ ─┬─────────────
│ ╰─ Missing translation in de.json (missing-translation)Formats
Both .json and .po catalogs are supported out of the box, making this tool suitable both for use with useTranslations as well as useExtracted.
If you’re using a custom format with useExtracted, you can configure this for @eloqnt/cli as well:
import {defineConfig} from '@eloqnt/cli';
export default defineConfig({
messages: {
format: {
codec: './StructuredJSONCodec.ts',
extension: '.json'
}
// ...
}
});See custom formats in the @eloqnt/cli docs.
GitHub Actions
eloqnt lint can be integrated on continuous integration systems like GitHub Actions, while optionally also filling in missing translations.
See GitHub Actions in the @eloqnt/cli docs.