Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Translation and Key Shortening Tool

A Node.js application that provides two utilities:

  1. Translation Tool: Translate JSON strings to multiple languages using Google Translate API
  2. Key Shortening Tool: Shorten JSON keys by removing vowels and converting to camelCase

Prerequisites

  • Node.js (v12 or higher)
  • Google Cloud Project with Translation API enabled
  • Google Cloud Service Account with Translation API access

Installation

  1. Clone the repository and install dependencies:

    npm install
  2. Set up Google Cloud credentials:

    • Place your service account JSON file as credentials.json in the project root
    • Create a .env file with required variables:
      GOOGLE_CLOUD_PROJECT_ID=your-project-id
      TARGET_LANGUAGES=es,fr,de,pl
      

Usage

Translation Tool

Translate strings from English to multiple target languages:

npm run translate

Input: 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)

Key Shortening Tool

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

Configuration

  • Target Languages: Set TARGET_LANGUAGES in your .env file (comma-separated ISO 639-1 codes)
  • Vowel Pattern: Modify VOWEL_PATTERN in shortenKeys.js to customize shortening rules

Project Structure

├── 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

About

Translation and Key Shortening Tool

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages