A superfast i18next scanner tool written in Rust, based on Oxc
The node.js API is implemented by NAPI
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
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)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>>For a detailed explanation on how things work, checkout the Oxc and NAPI doc
Copyright (c) 2025-present, Idler.zhu