Skip to main content
The check command scans your codebase for translation key usage and reports unused keys in your source file and missing keys that are referenced but not defined.

Usage

npx lazylocales check [options]

Options

FlagDescription
--jsonOutput machine-readable JSON

What it does

1

Load source file

Reads your source locale file and extracts all translation keys.
2

Scan codebase

Recursively scans your project for translation function calls:
  • t('namespace.key') — i18next/react-i18next
  • formatMessage({ id: 'namespace.key' }) — react-intl
Scans TypeScript, JavaScript, Vue, Svelte, and Astro files.
3

Report findings

Shows three lists:Used keys — keys found in both source file and codebaseUnused keys — keys in source file but not referenced in codeMissing keys — keys referenced in code but not in source file
✓ 138 keys in source file
✓ 135 keys used in codebase

⚠ 3 unused keys (in source but not in code):
  • settings.notifications.sms
  • auth.passwordResetExpired
  • dashboard.chartLegend

⚠ 0 missing keys (in code but not in source)

Summary:
  Used:    135
  Unused:  3
  Missing: 0

Examples

Check for unused/missing keys:
npx lazylocales check
Get results as JSON:
npx lazylocales check --json

Notes

The command scans .ts, .tsx, .js, .jsx, .vue, .svelte, and .astro files.It skips directories like node_modules, .git, .next, dist, build, .turbo, .vercel, and coverage.
The command uses regex patterns to find translation function calls:
  • Pattern 1: t('namespace.key') — matches i18next
  • Pattern 2: formatMessage({ id: 'namespace.key' }) — matches react-intl
Only keys with at least one dot (e.g., auth.login) are counted to avoid false positives from other APIs like path.split('.') or .get('Authorization').
Dynamic keys like t(\errors.$`)` are not detected by this command.If you use dynamic key construction, you may see “unused” warnings for keys that are actually used dynamically.
Run check periodically to:
  • Find dead keys that can be removed
  • Catch missing translations before runtime errors
  • Keep your locale files clean and maintainable
Consider adding it to your CI pipeline to catch missing keys in pull requests.