neeto-translate-cli

A Ruby CLI tool that extracts translation files from Rails applications and makes requests to the neeto-translate API for automated translation management.

Table of Contents

Installation

Install the gem via RubyGems:

gem install neeto-translate-cli

Or add it to your Gemfile:

gem 'neeto-translate-cli'

Then run:

bundle install

Usage

The neeto-translate-cli tool helps you manage translations by:

  1. Extracting translation keys from your Rails application's frontend (JSON) and backend (YAML) locale files
  2. Identifying missing translations across different languages
  3. Detecting updated translation keys since the last automated translation
  4. Sending translation requests to the neeto-translate API

Basic Usage

neeto-translate-cli [OPTIONS]

Command line options

Options:

  • --frontend PATH - Path to frontend locales (default: app/javascript/src/translations)
  • --backend PATH - Path to backend locales (default: config/locales)
  • --defaults LANGUAGES - Comma-separated list of languages to translate (default: en,fr,de,es)
  • --repo NAME - GitHub repository name (e.g., neetozone/neeto-cal-web)

Examples

Custom paths:

neeto-translate-cli --frontend src/locales --backend config/translations

Specific languages:

neeto-translate-cli --defaults "fr,de,es,it"

Full example:

neeto-translate-cli \
  --frontend app/javascript/src/translations \
  --backend config/locales \
  --defaults "fr,de,es" \
  --repo "neetozone/neeto-cal-web"

Environment Variables

The following environment variables can be configured:

  • NEETO_TRANSLATE_URL - Base URL for the neeto-translate API (default: https://translate.neeto.com)
  • NEETO_TRANSLATE_X_TOKEN - Authentication token for the API
  • DEFAULT_LANGUAGES - Comma-separated list of default languages (default: en,fr,de,es)

How It Works

  1. Extraction: The tool reads your English translation files (en.json for frontend, en.yml for backend)
  2. Analysis: It compares with other language files to identify missing translations
  3. Change Detection: It detects keys that have been updated since the last automated translation run
  4. API Request: Sends a payload to the neeto-translate API with:
    • Current English translations
    • Missing translation keys for each language
    • Updated keys that need re-translation
    • Repository metadata

Development

Setup

  1. Clone the repository:
git clone https://github.com/neetozone/neeto-translate.git
cd neeto-translate/cli
  1. Install dependencies:
bundle install
  1. Run tests:
bundle exec rake test