WordSmith

WordSmith is a powerful CLI tool that leverages OpenAI's API to translate words, phrases, and sentences. It supports context-aware translations, batch processing from files, and customizable target languages, making it an essential tool for multilingual communication and language learning.

MIT License

Stars
1

WordSmith

WordSmith is a command-line tool for translating words, phrases, and words in context of a sentence.

Features

  • Translate single words or phrases
  • Translate words within the context of a sentence
  • Read words from a file for batch translation
  • Optional caching for faster repeated translations
  • Specify target language for translations

Installation

  1. Ensure you have Ruby installed on your system (version 2.7 or higher recommended).

  2. Install the WordSmith gem:

gem install word_smith
  1. Set up your OpenAI API key and Organization ID:
ws --set-openai-api-key YOUR_API_KEY
ws --set-openai-org-id YOUR_ORG_ID

Replace YOUR_API_KEY and YOUR_ORG_ID with your actual OpenAI credentials.

Usage

Basic usage:

ws [word/phrase] [options]

Examples:

  1. Translate a single word:
ws hello
  1. Translate a phrase:
ws good morning
  1. Translate a word in context:
ws a /random/ sentence
  1. Translate words from a file:
ws -f words.txt
  1. Translate to a specific language:
ws hello --target-language Spanish
  1. Translate without using cache:
ws hello --no-cache

Options:

  • -f, --file [FILE_PATH]: Read words from a file
  • --target-language [LANGUAGE_CODE]: Specify target language for translation
  • --no-cache: Translate without using cache
  • -h, --help: Show help
  • -v, --version: Show version

Configuration

Set OpenAI API key:

ws --set-openai-api-key [key]

Set OpenAI Organization ID:

ws --set-openai-org-id [key]

License

MIT