nativtongue-cli
v0.0.4
Published
CLI and dev tooling for nativtongue — extract, sync, and translate
Maintainers
Readme
nativtongue-cli
Dev tooling for nativtongue — extracts translation keys from your source code, generates translation files, and auto-translates via Claude.
Install
npm install -D nativtongue-cliRequires Claude Code installed and authenticated for auto-translation.
Quick start
npx nativtongue init fr es deThis:
- Creates
.nativtonguerc.jsonwith your locales - Patches
vite.config.tsto add thetongueSync()plugin - Creates the
public/i18n/directory - Adds
.nativtongue/to.gitignore
Then start your dev server. Translations sync automatically as you write code.
Commands
nativtongue init <locales...>
Set up nativtongue in your project.
nativtongue init fr # French only
nativtongue init fr es de ja # Multiple localesnativtongue sync
Extract keys from source files and update translation files.
nativtongue sync # Extract keys, add empty values for new ones
nativtongue sync --translate # Extract + auto-translate missing keys via Claude
nativtongue sync --prune # Remove stale keys no longer in source
nativtongue sync --translate --prune # BothVite plugin
The tongueSync() plugin watches your source files during development and automatically extracts keys + translates on save.
// vite.config.ts
import { tongueSync } from 'nativtongue-cli/sync'
export default defineConfig({
plugins: [tongueSync()],
})How it works
- On dev server start, scans all source files and extracts translation keys
- On file save, re-extracts keys from the changed file (5s debounce)
- Diffs against the last known key set — if nothing changed, does nothing
- Translates new keys via
claude -p(parallel across locales) - Writes updated locale files (e.g.
public/i18n/fr.json)
Options
tongueSync({
srcDir: './src', // default: from .nativtonguerc.json or './src'
i18nDir: './public/i18n', // default: from .nativtonguerc.json or './public/i18n'
locales: ['fr', 'es'], // default: from .nativtonguerc.json
})What gets extracted
The static extractor finds:
- Plain text inside JSX elements (
<p>Hello</p>,<h1>Welcome</h1>) t("...")calls from theuseT()hook- Translatable attributes (
aria-label,placeholder,title,alt) - Scoped keys inside
<TranslationScope>(e.g.navigation::Back)
Configuration
.nativtonguerc.json in your project root:
{
"srcDir": "./src",
"i18nDir": "./public/i18n",
"locales": ["fr", "es", "de"]
}