slt-js
raw JSON → 0.2.0 verified Fri May 01 auth: no javascript
SLT (Script Localization Tool) transpiler for JavaScript that replaces localized keywords in ES (Spanish), FR (French), and IT (Italian) source files with canonical JavaScript keywords. Version 0.2.0, pre-1.0, with no scheduled release cadence. Differentiators: simple reference implementation with header-based language detection (#!slt <lang>), custom mapping support, and CLI. Limitations: not a full JS tokenizer, may mishandle regex literals; not production-ready.
Common errors
error slt-js: error: cannot read file 'nonexistent.js' ↓
cause File not found.
fix
Check file path and ensure the file exists.
error Error: No language header found. Use #!slt <lang> at the top of the file. ↓
cause Missing or malformed SLT header on first line.
fix
Add '#!slt es' (or fr/it) as the first line of the source file.
error slt-js: error: Invalid mapping file 'bad.json' ↓
cause JSON parse error or invalid structure.
fix
Ensure mapping file is valid JSON with key-value pairs: { "localized": "canonical" }.
Warnings
gotcha SLT header must be exactly at line 1, no leading whitespace. ↓
fix Ensure the file starts with '#!slt <lang>' on the first line, no BOM or spaces.
gotcha Transpiler is not token-aware and may modify strings or comments if they contain localized keywords. ↓
fix Avoid using localized keywords inside strings or comments, or use a full parser like @babel/parser.
gotcha Only three built-in languages: es, fr, it. ↓
fix Use --map to provide a custom mapping file for other languages.
Install
npm install slt-js yarn add slt-js pnpm add slt-js Imports
- slt-js (CLI) wrong
npx slt-js <file> (does not expose programmatic API)correctslt-js <file> [options]
Quickstart
// example-esp.js
#!slt es
function saludar(nombre) {
consola.escribir('Hola, ' + nombre);
}
// Install globally: npm install -g slt-js
// Transpile: slt-js example-esp.js -o example.js
// Output:
// function saludar(nombre) {
// console.log('Hola, ' + nombre);
// }