Skip to content

BuriXon-code/polyglotSH

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

spolyglotSH

About

spolyglotSH is a full-featured command-line translator written in Bash. It uses the Google Translate web endpoint to translate text or files directly from the terminal. Designed for CLI workflows, it supports multiple input sources, automatic language detection, and provides safeguards for file size, binary content, and network errors. Ideal for quick translations, scripting, and pipelines.

screenshot

Features

  • Translate text directly from a string, a file, or piped input.
  • Automatic source language detection with override option.
  • Supports over 100 languages using standard language codes.
  • Validates input files to prevent processing of binary files.
  • Enforces a maximum file size of 4MB to avoid performance issues.
  • Handles network errors, invalid API responses, and parsing errors gracefully.
  • Lists all supported languages with their codes.
  • Outputs clean translation suitable for piping or saving to a file.

Installation

  1. download repository:
git clone https://github.com/BuriXon-code/polyglotSH && cd polyglotSH
  1. add permissions:
chmod +x translator

Usage

Options

  • -q : Translate a text string provided directly.
  • -f : Translate content from a text file. Binary files are rejected. Maximum allowed size: 4MB.
  • -t : Target language (required). Use standard language codes (e.g., en, pl, fr).
  • -s : Source language (default: auto).
  • -l : List all supported languages.
  • -h : Display help information and usage instructions.

Examples

  • Translate a string provided directly through a flag:
translator -t en -q "Testuję translator."
  • Translate the content of a text file.
translator -t en -f /path/to/file
  • Translate text piped from another command or input source.
some-command | translator -t de
  • List all supported languages.
translator -l

Dependencies

  • Bash 4+
  • curl for HTTP requests
  • jq for JSON parsing
  • Internet connection to access Google Translate

Compatibility

  • Works on Linux, macOS, and WSL/Unix-like systems.
  • Supports UTF-8 encoded text files only.
  • Input files must not exceed 4MB.
  • Rejects binary files to prevent corruption.
  • Outputs translation cleanly to stdout, safe for piping and redirection.

Versions

Available versions of the program:

  • [GO] - polyglot - program written in GO, high compatibility, control, excellent error handling;
  • [BASH] - polyglotSH - Bash script, high compatibility, easy installation;
  • [PHP] - polyglotPHP - PHP CLI script, high speed, versatility;
  • [Python] - polyglotPY - Python script, high compatibility, stability.

License

OSL-3.0 — see the LICENSE file in the repository.

Support

Contact me:

For any issues, suggestions, or questions, reach out via:

Support me:

If you find this script useful, consider supporting my work by making a donation:

Donations

Your contributions help in developing new projects and improving existing tools!

About

Easily translate the contents of files and stdin into other languages.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages