json-translator-cli
v1.3.0
Published
CLI tool to translate JSON values while preserving keys
Maintainers
Readme
🚀 JSON Translator CLI
Translate only JSON values (not keys) safely and automatically.
Perfect for localization files like:
{
"Save": "Save",
"Cancel": "Cancel"
}✨ Features
✅ Translate only values, keys remain unchanged
🧠 Only-missing mode (translates only if key === value)
⚡
--forcemode (translate all values)🔒 Placeholder protection
%1{count}:name
🔁 Works with:
- Nested objects
- Arrays
🚀 Built-in cache (faster translations)
💻 CLI ready (global command)
📦 Installation
1. Clone repo
git clone https://github.com/YOUR_USERNAME/json-translator.git
cd json-translator2. Install dependencies
npm install3. Build
npm run build4. Link globally
sudo npm link⚙️ Requirements
This project uses translate-shell.
Install it:
sudo pacman -S translate-shellTest:
trans :uz "Hello"🚀 Usage
Dev mode
npm run dev -- input.json output.json --to uz --forceBuild mode
node dist/index.js input.json output.json --to uz --forceGlobal command
jtr input.json output.json --to uz --force🧪 Examples
Input
{
"Save": "Save",
"Cancel": "Cancel"
}Output
{
"Save": "Saqlash",
"Cancel": "Bekor qilish"
}🧠 Modes
Default (only-missing)
jtr input.json output.jsonOnly translates when:
"Save": "Save"Force mode
jtr input.json output.json --forceTranslates all values:
"welcome": "Hello, %1"➡️
"welcome": "Salom, %1"🔒 Placeholder Protection
Supported patterns:
%1{count}:name
Example:
{
"msg": "Hello, %1",
"count": "You have {count} messages"
}Output:
{
"msg": "Salom, %1",
"count": "Sizda {count} ta xabar bor"
}📁 Project Structure
src/
index.ts
translator/
walk.ts
translate.ts
placeholders.ts🛠 Tech Stack
- Node.js
- TypeScript
- Commander
- translate-shell
- execa
🔥 Roadmap
- [ ] Progress bar
- [ ] Batch translation (faster)
- [ ] Backup & overwrite flags
- [ ] Translation report
- [ ] Config file support
👤 Author
NR_Stylle
⭐ Support
If you like this project, give it a ⭐ on GitHub!
