localize-core-cli
v1.0.0
Published
Production-grade deterministic localization + CloudFront migration platform. No AI required. Works fully offline.
Maintainers
Readme
localize-core-cli
Production-grade deterministic localization + CloudFront CDN migration platform. No AI required. Works fully offline. Zero LLM dependencies.
What is this?
localize-core-cli is an enterprise-grade CLI + npm package that automates:
- Localization — scan, extract, transform, and validate i18n strings across React, Angular, Vue, Next.js, and legacy codebases
- CDN migration — detect legacy CDN URLs, upload assets to S3, generate CloudFront URLs, and replace all references in source code
All operations are fully deterministic and 100% offline — no OpenAI, Claude, Gemini, or any cloud AI is used or required.
Install
npm install -g localize-core-cli
# or
npx localize-core-cli <command>Quick Start
# 1. Initialize config in your project root
npx ai-localize init
# 2. Scan for hardcoded UI text
npx ai-localize scan
# 3. Extract and generate locale JSON files
npx ai-localize extract
# 4. Validate locale files (missing keys, duplicates, placeholders)
npx ai-localize validate
# 5. Generate HTML + JSON report
npx ai-localize report
# 6. Run full pipeline (scan → extract → codemod → report)
npx ai-localize full-migrate
# Dry-run preview without writing files
npx ai-localize full-migrate --dry-runConfig
Running ai-localize init creates ai-localize.config.json in your project root:
{
"framework": "react",
"srcDir": "src",
"defaultLanguage": "en",
"targetLanguages": ["fr", "de"],
"localesDir": "src/i18n/locales",
"aws": {
"bucket": "my-s3-bucket",
"distributionId": "E1234ABCDEF",
"region": "us-east-1"
}
}Programmatic API
const {
Scanner,
Validator,
Reporter,
LocaleEngine,
CodemodEngine,
FrameworkDetector,
loadConfig,
} = require('localize-core-cli');
// Scan for hardcoded strings
const scanner = new Scanner({
rootDir: './src',
extensions: ['.tsx', '.ts', '.jsx', '.js'],
excludeDirs: ['node_modules', 'dist'],
});
const { detectedTexts, filesScanned } = await scanner.scan();
// Generate locale files
const le = new LocaleEngine('./', {
defaultLanguage: 'en',
targetLanguages: ['fr', 'de'],
localesDir: './src/i18n/locales',
});
const keyMap = le.generateFromDetectedTexts(detectedTexts, 'en', 'common');
le.syncLanguages('common');
le.persistAll();
// Validate
const validator = new Validator({
baseLanguage: 'en',
targetLanguages: ['fr', 'de'],
locales: { en: keyMap },
sourceTexts: detectedTexts,
});
const { missingKeys, duplicateKeys } = validator.validate();
// Report
const reporter = new Reporter();
reporter.generateCLI({ filesScanned, hardcodedTexts: detectedTexts.length });
// Codemods — inject useTranslation + t() wrappers
const ce = new CodemodEngine({ framework: 'react' });
const codeKeyMap = ce.buildKeyMap(detectedTexts);
const { code, modified } = ce.transformFile(sourceCode, codeKeyMap);Supported Frameworks
| Framework | Detection | Scanning | Codemod | |-----------|-----------|----------|---------| | React (CRA, Vite, Next.js) | ✅ | ✅ | ✅ | | Angular (ngx-translate, Angular i18n) | ✅ | ✅ | ✅ | | Vue (vue-i18n) | ✅ | ✅ | ✅ | | Legacy (jQuery, Vanilla JS, JSP) | ✅ | ✅ | — |
Detected Text Types
- JSX text nodes
- String literals in JS/TS
- HTML
placeholder,title,aria-labelattributes - Modal / Toast / Alert messages
- Tooltip content
- Table headers
- Button labels
- Form validation messages
- Heading content
CLI Commands
| Command | Description |
|---------|-------------|
| ai-localize init | Initialize ai-localize.config.json |
| ai-localize scan | Scan source files for hardcoded text |
| ai-localize extract | Generate locale JSON files |
| ai-localize validate | Validate locale completeness |
| ai-localize report | Generate JSON + HTML reports |
| ai-localize full-migrate | Full pipeline: scan → extract → codemod → report |
| ai-localize full-migrate --dry-run | Preview without writing files |
AWS CloudFront CDN Migration
Configure your AWS credentials in environment variables or ~/.aws/credentials, then:
ai-localize upload-assets # Hash and upload assets to S3
ai-localize replace-cdn # Replace legacy CDN URLs with CloudFront URLs
ai-localize migrate-cdn # Full CDN migration pipelineDetects and replaces:
- Hardcoded CDN URLs in source files
- CSS
background-imagereferences <img src>attributes- Environment variable CDN configs
- Webpack / Vite public path configs
Locale Key Generation
Keys are generated deterministically from file path + component name + text:
src/pages/campaign/CreateCampaign.tsx
"Save Campaign"
→ campaign.create.save_campaignFeatures
- ✅ Zero AI / LLM — fully deterministic
- ✅ Works offline
- ✅ AST-based scanning (Babel parser)
- ✅ Format-preserving codemods (recast)
- ✅ Incremental scanning (git diff / staged files)
- ✅ Worker thread parallelism
- ✅ Plugin system
- ✅ Monorepo support
- ✅ CI/CD ready (GitHub Actions, GitLab CI, Bitbucket Pipelines)
- ✅ VS Code extension included
License
MIT © smaeeraabdul
