A Node.js application that provides two utilities:
- Translation Tool: Translate JSON strings to multiple languages using Google Translate API
- Key Shortening Tool: Shorten JSON keys by removing vowels and converting to camelCase
- Node.js (v12 or higher)
- Google Cloud Project with Translation API enabled
- Google Cloud Service Account with Translation API access
-
Clone the repository and install dependencies:
npm install
-
Set up Google Cloud credentials:
- Place your service account JSON file as
credentials.jsonin the project root - Create a
.envfile with required variables:GOOGLE_CLOUD_PROJECT_ID=your-project-id TARGET_LANGUAGES=es,fr,de,pl
- Place your service account JSON file as
Translate strings from English to multiple target languages:
npm run translateInput: Place your English strings in input/en.json
{
"Save and continue": "Save and continue",
"Cancel": "Cancel"
}Output: Translated files will be created in output/ directory (e.g., output/es.json, output/pl.json)
Shorten JSON keys by removing vowels while preserving readability:
npm run shorten [input-file] [output-file]Example:
node shortenKeys.js input/en.json input/en_shortened.json- Target Languages: Set
TARGET_LANGUAGESin your.envfile (comma-separated ISO 639-1 codes) - Vowel Pattern: Modify
VOWEL_PATTERNinshortenKeys.jsto customize shortening rules
├── input/ # Input JSON files
├── output/ # Generated translation files
├── translate.js # Main translation script
├── shortenKeys.js # Key shortening utility
├── package.json # Project dependencies and scripts
└── README.md # This file