@i18n-scanner-rs/main
v0.2.13
Published
A superfast i18next scanner tool written in Rust, based on Oxc
Readme
I18n scanner rs
A superfast i18next scanner tool written in Rust, based on Oxc
The node.js API is implemented by NAPI
How it works
This will follow the below flows to collect all the I18n contents via passed entry file
- Analyze all file references from entry files
- Find all import statements are includes the list below:
- import * from 'i18next'
- import * from 'react-i18next'
- or any you passed packages
- find out the variable linked to the import statement
- recursively analyze the variable's references
- collect the first parameter of i18n function call or bypass from another function wrapped by the i18n function
Usage
import { scan } from '@i18n-scanner-rs/main'
const payload = {
tsconfigPath: './tsconfig.json',
entryPaths: ['./src/index.ts'],
externals: ['react-i18next'],
extendI18NPackages: [],
}
const result = scan(payload)
console.log(result)Debug parsing / syntax compatibility issues
If a file uses syntax that is not fully supported by the current parser version, run with debug logs to locate the problematic file quickly:
RUST_LOG=debug node your-script.jsThe scanner will print parse diagnostics (including file paths) so you can identify and isolate unsupported syntax.
Type declarations
export interface Member {
name: string
type: I18nType
ns?: string
}
export interface I18NPackage {
packagePath: string
members: Array<Member>
}
export const enum I18nType {
Hook = 'Hook',
TMethod = 'TMethod',
TransComp = 'TransComp',
TranslationComp = 'TranslationComp',
HocWrapper = 'HocWrapper',
ObjectMemberT = 'ObjectMemberT',
}
export interface Payload {
tsconfigPath: string
entryPaths: Array<string>
externals: Array<string>
extendI18NPackages?: Array<I18NPackage>
}
export declare function scan(payload: Payload): Record<string, Array<string>>License
For a detailed explanation on how things work, checkout the Oxc and NAPI doc
Copyright (c) 2025-present, Idler.zhu
