oio11: (Default)
[personal profile] oio11
Translate Shell
Icon Build Status Version Download Gitter
Translate Shell (formerly Google Translate CLI) is a command-line translator powered by Google Translate. It gives you easy access to Google Translate in your terminal:
$ trans 'Saluton, Mondo!' Saluton, Mondo!  Hello, World!  Translations of Saluton, Mondo! [ Esperanto -> English ] Saluton ,     Hello, Mondo !     World!
By default, translations with detailed explanations are shown. You can also translate the text briefly: (only the most relevant translation will be shown)
$ trans -brief 'Saluton, Mondo!' Hello, World!
Translate Shell can also be used like an interactive shell; input the text to be translated line by line:
$ trans -shell -brief > Rien ne réussit comme le succès. Nothing succeeds like success. > Was mich nicht umbringt, macht mich stärker. What does not kill me makes me stronger. > Юмор есть остроумие глубокого чувства. Humor has a deep sense of wit. > 學而不思則罔,思而不學則殆。 Learning without thought is labor lost, thought without learning is perilous. > 幸福になるためには、人から愛されるのが一番の近道。 In order to be happy, the best way is to be loved by people.

PREREQUISITES

System Requirements

Translate Shell is known to work on many POSIX-compliant systems, including but not limited to:
  • GNU/Linux
  • OS X
  • FreeBSD
  • Windows (Cygwin or MSYS2)

Dependencies

  • GNU Awk (gawk4.0 or later
    • This program relies heavily on GNU extensions of the AWK language, which are non-portable for other AWK implementations (e.g. nawk).
    • How to get gawk:
    • gawk comes with all GNU/Linux distributions.
    • On FreeBSD, gawk is available in the ports.
    • On OS X, gawk is available in MacPorts and Homebrew.
  • GNU Bash or Zsh
    • You may use Translate Shell from any Unix shell of your choice (bash, zsh, ksh, tcsh, fish, etc.); however, the wrapper script requires either bash or zsh installed.

Optional Dependencies

  • GNU FriBidian implementation of the Unicode Bidirectional Algorithm (bidi)
    • required for displaying text in Right-to-Left scripts (e.g. Arabic, Hebrew)
  • mplayermplayer2mpvmpg123, or eSpeak
    • required for the Text-to-Speech functionality
  • lessmore or most
    • required for terminal paging
  • rlwrapa GNU readline wrapper
    • required for readline-style editing and history in the interactive shell
  • curl with OpenSSL support
    • required for secured URL fetching (checking for upgrade, etc.)

Environment and Fonts

It is a must to have corresponding fonts for the language(s) / script(s) you wish to display in your terminal. See wiki: Writing Systems and Fonts for more details on scripts and recommended Unicode fonts.

TRY IT OUT!

Start an interactive shell and translate anything you input into your native language: (in bash or zsh)
$ gawk -f <(curl -Ls git.io/translate) -shell
(in fish)
$ gawk -f (curl -Ls git.io/translate | psub) -shell
Please make sure to read the disclaimer before using.

INSTALLATION

Option #1. Direct Download

Download the self-contained executable and place it into your path. It's everything you need.
$ wget git.io/trans $ chmod +x ./trans
There is a GPG signature.

Option #2. From Git

$ git clone https://github.com/soimort/translate-shell $ cd translate-shell/ $ make $ [sudo] make install
In case you have only zsh but not bash in your system, build with:
$ make TARGET=zsh
The default PREFIX of installation is /usr/local. To install the program to somewhere else (e.g. /usr~/.local), use:
$ [sudo] make PREFIX=/usr install

Option #3. From A Package Manager

On OS X with Homebrew:
$ brew install http://www.soimort.org/translate-shell/translate-shell.rb
On Linux, you may ignore its dependencies (e.g. gawk) if you already have them in your system:
$ brew install --ignore-dependencies http://www.soimort.org/translate-shell/translate-shell.rb
See wiki: Distros on how to install from a specific package manager on your distro.

INTRODUCTION BY EXAMPLES

Translate a Word

From any language to your language

Google Translate can identify the language of the source text automatically, and Translate Shell by default translates the source text into the language of your locale.
$ trans vorto

From any language to one or more specific languages

Translate a word into French:
$ trans :fr word
Translate a word into Chinese and Japanese: (use a plus sign "+" as the delimiter)
$ trans :zh+ja word
Alternatively, equals sign ("=") can be used in place of the colon (":"). Note that in some shells (e.g. zsh), equals signs may be interpreted differently, therefore the argument specifying languages needs to be protected:
$ trans {=zh+ja} word $ trans '=zh+ja' word
You can also use the -target (-t) option to specify the target language(s):
$ trans -t zh+ja word

From a specific language

Google Translate may wrongly identify the source text as some other language than you expected:
$ trans 手紙
In that case, you need to specify its language explicitly:
$ trans ja: 手紙 $ trans zh: 手紙
You can also use the -source (-s) option to specify the source language:
$ trans -s ja 手紙

Translate Multiple Words or a Phrase

Translate each word alone:
$ trans en:zh word processor
Put words into one argument, and translate them as a whole:
$ trans en:zh "word processor"

Translate a Sentence

Translating a sentence is much the same like translating a phrase; you can just quote the sentence into one argument:
$ trans :zh "To-morrow, and to-morrow, and to-morrow," $ trans :zh 'To-morrow, and to-morrow, and to-morrow,'
It is also possible to translate multi-line sentences:
$ trans :zh "Creeps in this petty pace from day to day, > To the last syllable of recorded time; > And all our yesterdays have lighted fools > The way to dusty death."
To avoid punctuation marks (e.g. "!") or other special characters being interpreted by the shell, use single quotes:
$ trans :zh 'Out, out, brief candle!'
There are some cases though, you may still want to use double quotes: (e.g. the sentence contains a single quotation mark "'")
$ trans :zh "Life's but a walking shadow, a poor player"

Brief Mode

By default, Translate Shell displays translations in a verbose manner. If you prefer to see only the most relevant translation, there is a brief mode available using the -brief (-b) option:
$ trans -b :fr "Saluton, Mondo"
In brief mode, phonetic notation (if any) is not shown by default. To enable this, put an at sign "@" in front of the language code:
$ trans -b :@ja "Saluton, Mondo"

Dictionary Mode

Google Translate can be used as a dictionary. When translating a word and the target language is the same as the source language, the dictionary entry of the word is shown:
$ trans :en word
To enable dictionary mode no matter whether the source language and the target language are identical, use the -dictionary (-d) option.
$ trans -d fr: mot
Note: Not every language supported by Google Translate has provided dictionary data. See wiki: Languages to find out which language(s) has dictionary support.

Text-to-Speech

Use the -play (-p) option to listen to the translation:
$ trans -b -p :ja "Saluton, Mondo"

Terminal Paging

Sometimes the content of translation can be too much for display in one screen. Use the -view (-v) option to view the translation in a terminal pager such as less or more:
$ trans -d -v word

Right-to-Left (RTL) Languages

Right-to-Left (RTL) languages are well supported via GNU FriBidi.
The program will automatically adjust the screen width for padding when displaying right-to-left languages. Alternatively, you may use the -width(-w) option to specify the screen width:
$ trans -b -w 40 :he "Saluton, Mondo"
See wiki: Languages to find out which language(s) uses a Right-to-Left writing system.

Pipeline, Input and Output

If no source text is given in command-line arguments, the program will read from standard input, or from the file specified by the -input (-i) option:
$ echo "Saluton, Mondo" | trans -b :fr $ trans -b -i input.txt :fr
Translations are written to standard output, or to the file specified by the-output (-o) option:
$ echo "Saluton, Mondo" | trans -b -o output.txt :fr

Translate a File

Instead of using the -input option, a file URI scheme (file:// followed by the file name) can be used as a command-line argument:
$ trans :fr file://input.txt
Note: Brief mode is used when translating from file URI schemes.

Translate a Web Page

To translate a web page, an http(s) URI scheme can be used as an argument:
$ trans :fr http://www.w3.org/
A browser session will open for viewing the translation (via Google Translate's web interface). To specify your web browser of choice, use the-browser option:
$ trans -browser firefox :fr http://www.w3.org/

Language Details

Use the -list (-L) option to view details of one or more languages:
$ trans -L fr $ trans -L de+en
Some basic information of the language will be displayed: its English name and endonym (language name in the language itself), language family, writing system, canonical Google Translate code and ISO 639-3 code.

Interactive Translate Shell (REPL)

Start an interactive shell using the -shell (or -interactive-I) option:
$ trans -shell
You may specify the source language and the target language(s) before starting an interactive shell:
$ trans -shell en:fr
You may also change these settings during an interactive session. See wiki: REPL for more advanced usage of the interactive Translate Shell.

USAGE

For more details on command-line options, see the man page trans(1) or use trans -M in a terminal.
Usage:  trans [OPTIONS] [SOURCE]:[TARGETS] [TEXT]...  Information options:     -V, -version         Print version and exit.     -H, -help         Print help message and exit.     -M, -man         Show man page and exit.     -T, -reference         Print reference table of languages and exit.     -R, -reference-english         Print reference table of languages (in English names) and exit.     -L CODES, -list CODES         Print details of languages and exit.     -U, -upgrade         Check for upgrade of this program.  Display options:     -verbose         Verbose mode. (default)     -b, -brief         Brief mode.     -d, -dictionary         Dictionary mode.     -show-original Y/n         Show original text or not.     -show-original-phonetics Y/n         Show phonetic notation of original text or not.     -show-translation Y/n         Show translation or not.     -show-translation-phonetics Y/n         Show phonetic notation of translation or not.     -show-prompt-message Y/n         Show prompt message or not.     -show-languages Y/n         Show source and target languages or not.     -show-original-dictionary y/N         Show dictionary entry of original text or not.     -show-dictionary Y/n         Show dictionary entry of translation or not.     -show-alternatives Y/n         Show alternative translations or not.     -w NUM, -width NUM         Specify the screen width for padding.     -indent NUM         Specify the size of indent (number of spaces).     -theme FILENAME         Specify the theme to use.     -no-theme         Do not use any other theme than default.     -no-ansi         Do not use ANSI escape codes.  Audio options:     -p, -play         Listen to the translation.     -player PROGRAM         Specify the audio player to use, and listen to the translation.     -no-play         Do not listen to the translation.  Terminal paging and browsing options:     -v, -view         View the translation in a terminal pager.     -pager PROGRAM         Specify the terminal pager to use, and view the translation.     -no-view         Do not view the translation in a terminal pager.     -browser PROGRAM         Specify the web browser to use.  Networking options:     -x HOST:PORT, -proxy HOST:PORT         Use HTTP proxy on given port.     -u STRING, -user-agent STRING         Specify the User-Agent to identify as.  Interactive shell options:     -I, -interactive, -shell         Start an interactive shell.     -E, -emacs         Start the GNU Emacs front-end for an interactive shell.     -no-rlwrap         Do not invoke rlwrap when starting an interactive shell.  I/O options:     -i FILENAME, -input FILENAME         Specify the input file.     -o FILENAME, -output FILENAME         Specify the output file.  Language preference options:     -l CODE, -hl CODE, -lang CODE         Specify your home language.     -s CODE, -sl CODE, -source CODE         Specify the source language.     -t CODES, -tl CODE, -target CODES         Specify the target language(s), joined by '+'.  Other options:     -no-init         Do not load any initialization script.  See the man page trans(1) for more information.

CODE LIST

Use trans -R or trans -T to view the reference table in a terminal.
For more details on languages and corresponding codes, see wiki: Languages.
LanguageCodeLanguageCodeLanguageCode
Afrikaans 
Afrikaans
afHawaiian 
ʻŌlelo Hawaiʻi
hawPortuguese
Português
pt
Albanian 
Shqip
sqHebrew 
עִבְרִית
hePunjabi 
ਪੰਜਾਬੀ
pa
Amharic 
አማርኛ
amHindi 
हिन्दी
hiRomanian 
Română
ro
Arabic 
العربية
arHmong 
Hmoob
hmnRomansh 
Rumantsch
rm
Armenian 
Հայերեն
hyHungarian 
Magyar
huRussian 
Русский
ru
Assamese 
অসমীয়া
asIcelandic 
Íslenska
isSamoan 
Gagana Sāmoa
sm
Azerbaijani 
Azərbaycanca
azIgbo 
Igbo
igScottish Gaelic 
Gàidhlig
gd
Bashkir 
башҡорт теле
baIndonesian 
Bahasa Indonesia
idSerbian 
српски
sr
Basque 
Euskara
euInterlingue 
Interlingue
ieSesotho 
Sesotho
st
Belarusian 
беларуская
beIrish 
Gaeilge
gaShona 
chiShona
sn
Bengali 
বাংলা
bnItalian 
Italiano
itSindhi 
سنڌي
sd
Bosnian 
Bosanski
bsJapanese 
日本語
jaSinhala 
සිංහල
si
Breton 
Brezhoneg
brJavanese 
Basa Jawa
jvSlovak 
Slovenčina
sk
Bulgarian 
български
bgKannada 
ಕನ್ನಡ
knSlovenian 
Slovenščina
sl
Catalan 
Català
caKazakh 
Қазақ тілі
kkSomali 
Soomaali
so
Cebuano 
Cebuano
cebKhmer 
ភាសាខ្មែរ
kmSpanish 
Español
es
Cherokee 
ᏣᎳᎩ
chrKinyarwanda 
Ikinyarwanda
rwSundanese 
Basa Sunda
su
Chichewa 
Nyanja
nyKorean 
한국어
koSwahili 
Kiswahili
sw
Chinese Simplified 
简体中文
zh-CNKurdish 
Kurdî
kuSwedish 
Svenska
sv
Chinese Traditional 
正體中文
zh-TWKyrgyz 
Кыргызча
kyTajik 
Тоҷикӣ
tg
Corsican 
Corsu
coLao 
ລາວ
loTamil 
தமிழ்
ta
Croatian 
Hrvatski
hrLatin 
Latina
laTatar 
татарча
tt
Czech 
Čeština
csLatvian 
Latviešu
lvTelugu 
తెలుగు
te
Danish 
Dansk
daLithuanian 
Lietuvių
ltThai 
ไทย
th
Dutch 
Nederlands
nlLuxembourgish
Lëtzebuergesch
lbTibetan 
བོད་ཡིག
bo
Dzongkha 
རྫོང་ཁ
dzMacedonian 
Македонски
mkTigrinya 
ትግርኛ
ti
English 
English
enMalagasy 
Malagasy
mgTurkish 
Türkçe
tr
Esperanto 
Esperanto
eoMalay 
Bahasa Melayu
msTurkmen 
Türkmen
tk
Estonian 
Eesti
etMalayalam 
മലയാളം
mlUkrainian 
Українська
uk
Faroese 
Føroyskt
foMaltese 
Malti
mtUrdu 
اُردُو
ur
Fijian 
Vosa Vakaviti
fjMaori 
Māori
miUyghur 
ئۇيغۇر تىلى
ug
Filipino 
Tagalog
tlMarathi 
मराठी
mrUzbek 
Oʻzbek tili
uz
Finnish 
Suomi
fiMongolian 
Монгол
mnVietnamese
Tiếng Việt
vi
French 
Français
frMyanmar 
မြန်မာစာ
myVolapük 
Volapük
vo
Galician 
Galego
glNepali 
नेपाली
neWelsh 
Cymraeg
cy
Georgian 
ქართული
kaNorwegian 
Norsk
noWestern Frisian 
Frysk
fy
German 
Deutsch
deOccitan 
Occitan
ocWolof 
Wollof
wo
Greek 
Ελληνικά
elOriya 
ଓଡ଼ିଆ
orXhosa 
isiXhosa
xh
Guarani 
Avañe'ẽ
gnOromo 
Afaan Oromoo
omYiddish 
ייִדיש
yi
Gujarati 
ગુજરાતી
guPashto 
پښتو
psYoruba 
Yorùbá
yo
Haitian Creole 
Kreyòl Ayisyen
htPersian 
فارسی
faZulu 
isiZulu
zu
Hausa 
Hausa
haPolish 
Polski
pl

WIKI

Lists of all languages, writing systems and fonts for reference:
The following pages demonstrate the advanced usage of Translate Shell:
Find out whether your Linux distribution has included Translate Shell in its official repository. If not, contribute one:
Frequently Asked Questions, historical stuff, AWK coding style, etc.:

HOW TO REPORT BUGS / CONTRIBUTE

Please review the guidelines for contributing before reporting an issue or sending a pull request.

DISCLAIMER

This software is provided for the purpose of reasonable personal use of the Google Translate service, i.e., for those who prefer command line to web interface. For other purposes, please refer to the official Google Translate API.
By using this software, you ("the user") are aware that:
  1. Google Translate is a proprietary service provided and owned by Google Inc.
  2. Translate Shell is NOT a Google product. Neither this software nor its author is affiliated with Google Inc.
  3. The software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

COPYRIGHT WAIVER

This is free and unencumbered software released into the public domain. See LICENSE and WAIVER for details.

This project is maintained by @soimort.

http://www.soimort.org/translate-shell/

October 2025

S M T W T F S
   1234
567891011
12131415161718
19202122 232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 22nd, 2026 04:24 am
Powered by Dreamwidth Studios