i18next-typescript-parser is a specialized utility library designed to accurately extract internationalization (i18n) keys from TypeScript codebases, tailored for use with the i18next framework. Unlike traditional parsers that might rely on less precise lexical analysis, this tool leverages a typed syntax tree (AST). This approach provides significantly enhanced reliability and precision in identifying translation keys within complex TypeScript structures, minimizing false positives and ensuring a more complete extraction compared to token-based methods. The current stable version is 0.3.2. As a 0.x.x series library, it is actively developed, and minor versions may introduce breaking changes. Its key differentiator is its robust, type-aware parsing mechanism, making it particularly valuable for maintaining accurate i18n key management in modern TypeScript projects.
npm install i18next-typescript-parserVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to import and use `extractKeys` to find i18next translation keys within a TypeScript file.
Consult the GitHub release notes for specific breaking changes. Pin your dependency to a patch version (e.g., `~0.3.2`) to mitigate unexpected updates, and test thoroughly before deploying new versions.
Ensure your `typescript` peer dependency aligns with the versions specified in `i18next-typescript-parser`'s `package.json` (`^5 || ^6`). Upgrade or downgrade your project's `typescript` version accordingly, or consider using a tool like `npm-check-updates` to help manage peer dependency versions.
Verify that your `tsconfig.json` correctly covers all relevant TypeScript files containing i18next keys. Ensure the `patterns` array passed to `extractKeys` accurately glob-matches the files you intend to process.
Install TypeScript: `npm install --save-dev typescript` or `yarn add --dev typescript`.
Ensure your Node.js environment supports ESM (Node.js 12+ with `"type": "module"` in `package.json` or by using a bundler like Webpack/Rollup if running in browser/transpiled environment). The library is primarily designed for ESM usage.
Double-check the `project` configuration passed to `extractKeys`. Ensure the `tsconfig` path is correct and accessible, and that `include`/`files` arrays within your `tsconfig` correctly point to the files you want to parse.