Giter VIP home page Giter VIP logo

translate-shell's Introduction

Translate Shell

Icon CircleCI Actions Version Download Gitter

Translate Shell (formerly Google Translate CLI) is a command-line translator powered by Google Translate (default), Bing Translator, Yandex.Translate, and Apertium. It gives you easy access to one of these translation engines 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
  • macOS
  • *BSD
  • Android (through Termux)
  • Windows (through WSL, Cygwin, or MSYS2)

Dependencies

  • GNU Awk (gawk) 4.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 macOS, gawk is available in MacPorts and Homebrew.
    • Please note that gawk 5.2.0 has a known bug -- update to gawk 5.2.1 instead.
  • 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.

Recommended Dependencies

These dependencies are optional, but strongly recommended for full functionality:

  • curl with OpenSSL support
  • GNU FriBidi: an implementation of the Unicode Bidirectional Algorithm (bidi)
    • required for displaying text in Right-to-Left scripts (e.g. Arabic, Hebrew)
  • mplayer, mpv, mpg123, or eSpeak
    • required for the Text-to-Speech functionality
  • less, more or most
    • required for terminal paging
  • rlwrap: a GNU readline wrapper
    • required for readline-style editing and history in the interactive shell
  • aspell or hunspell
    • required for spell checking

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 --compressed https://git.io/translate) -- -shell

(in fish)

$ gawk -f (curl -Ls --compressed https://git.io/translate | psub) -- -shell

Using Docker

To try out via Docker, run:

$ docker pull soimort/translate-shell

Then you may start an interactive shell from the Docker image for translating:

$ docker run -it soimort/translate-shell -shell

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 A Package Manager

Using your favorite package manager

See wiki: Distros on how to install from a specific package manager on your distro.

Using Antigen (for Zsh users)

Add the following line to your .zshrc:

antigen bundle soimort/translate-shell@develop

Option #3. 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

Getting Started 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

With the -t option, the name of the language may also be used instead of the language code:

$ trans -t japanese word
$ trans -t 日本語 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"

Alternatively, use the -join-sentence (-j) option to treat all arguments as one sentence so that quotes can be omitted:

$ trans -j :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.

Language Identification

Use the -identify (-id) option to identify the language of the text:

$ trans -id 言葉

Text-to-Speech

Use the -play (-p) option to listen to the translation:

$ trans -b -p :ja "Saluton, Mondo"

Use the -speak (-sp) option to listen to the original text:

$ trans -sp "你好,世界"

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 -linguist (-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] [SOURCES]:[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 (in endonyms) and codes, and exit.
    -R, -reference-english
        Print reference table of languages (in English names) and codes, and exit.
    -S, -list-engines
        List available translation engines and exit.
    -list-languages
        List all languages (in endonyms) and exit.
    -list-languages-english
        List all languages (in English names) and exit.
    -list-codes
        List all codes and exit.
    -list-all
        List all languages (endonyms and English names) and codes, and exit.
    -L CODES, -linguist CODES
        Print details of languages and exit.
    -U, -upgrade
        Check for upgrade of this program.

Translator options:
    -e ENGINE, -engine ENGINE
        Specify the translation engine to use.

Display options:
    -verbose
        Verbose mode. (default)
    -b, -brief
        Brief mode.
    -d, -dictionary
        Dictionary mode.
    -identify
        Language identification.
    -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.
    -no-autocorrect
        Do not autocorrect. (if defaulted by the translation engine)
    -no-bidi
        Do not convert bidirectional texts.
    -bidi
        Always convert bidirectional texts.
    -no-warn
        Do not write warning messages to stderr.
    -dump
        Print raw API response instead.

Audio options:
    -p, -play
        Listen to the translation.
    -speak
        Listen to the original text.
    -n VOICE, -narrator VOICE
        Specify the narrator, and 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.
    -no-translate
        Do not translate anything when using -speak.
    -download-audio
        Download the audio to the current directory.
    -download-audio-as FILENAME
        Download the audio to the specified file.

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, -no-pager
        Do not view the translation in a terminal pager.
    -browser PROGRAM
        Specify the web browser to use.
    -no-browser
        Do not open the web browser.

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.
    -4, -ipv4, -inet4-only
        Connect only to IPv4 addresses.
    -6, -ipv6, -inet6-only
        Connect only to IPv6 addresses.

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:
    -hl CODE, -host CODE
        Specify the host (interface) language.
    -s CODES, -sl CODES, -source CODES, -from CODES
        Specify the source language(s), joined by '+'.
    -t CODES, -tl CODES, -target CODES, -to CODES
        Specify the target language(s), joined by '+'.

Text preprocessing options:
    -j, -join-sentence
        Treat all arguments as one single sentence.

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.

Language Code Language Code Language Code
Afrikaans
Afrikaans
af Hebrew
עִבְרִית
he Portuguese (Brazilian)
Português Brasileiro
pt-BR
Albanian
Shqip
sq Hill Mari
Кырык мары
mrj Portuguese (European)
Português Europeu
pt-PT
Amharic
አማርኛ
am Hindi
हिन्दी
hi Punjabi
ਪੰਜਾਬੀ
pa
Arabic
العربية
ar Hmong
Hmoob
hmn Quechua
Runasimi
qu
Armenian
Հայերեն
hy Hungarian
Magyar
hu Querétaro Otomi
Hñąñho
otq
Assamese
অসমীয়া
as Icelandic
Íslenska
is Romanian
Română
ro
Aymara
Aymar aru
ay Igbo
Igbo
ig Romansh
Rumantsch
rm
Azerbaijani
Azərbaycanca
az Ilocano
Ilokano
ilo Russian
Русский
ru
Bambara
Bamanankan
bm Indonesian
Bahasa Indonesia
id Samoan
Gagana Sāmoa
sm
Bashkir
Башҡортса
ba Interlingue
Interlingue
ie Sanskrit
संस्कृतम्
sa
Basque
Euskara
eu Inuinnaqtun
Inuinnaqtun
ikt Scots Gaelic
Gàidhlig
gd
Belarusian
беларуская
be Inuktitut
ᐃᓄᒃᑎᑐᑦ
iu Sepedi
Sepedi
nso
Bengali
বাংলা
bn Inuktitut (Latin)
Inuktitut
iu-Latn Serbian (Cyrillic)
Српски
sr-Cyrl
Bhojpuri
भोजपुरी
bho Irish
Gaeilge
ga Serbian (Latin)
Srpski
sr-Latn
Bosnian
Bosanski
bs Italian
Italiano
it Sesotho
Sesotho
st
Breton
Brezhoneg
br Japanese
日本語
ja Setswana
Setswana
tn
Bulgarian
български
bg Javanese
Basa Jawa
jv Shona
chiShona
sn
Cantonese
粵語
yue Kannada
ಕನ್ನಡ
kn Sindhi
سنڌي
sd
Catalan
Català
ca Kazakh
Қазақ тілі
kk Sinhala
සිංහල
si
Cebuano
Cebuano
ceb Khmer
ភាសាខ្មែរ
km Slovak
Slovenčina
sk
Cherokee
ᏣᎳᎩ
chr Kinyarwanda
Ikinyarwanda
rw Slovenian
Slovenščina
sl
Chichewa
Nyanja
ny Klingon
tlhIngan Hol
tlh-Latn Somali
Soomaali
so
Chinese (Literary)
文言
lzh Konkani
कोंकणी
gom Spanish
Español
es
Chinese (Simplified)
简体中文
zh-CN Korean
한국어
ko Sundanese
Basa Sunda
su
Chinese (Traditional)
繁體中文
zh-TW Krio
Krio
kri Swahili
Kiswahili
sw
Chuvash
Чӑвашла
cv Kurdish (Central)
سۆرانی
ckb Swedish
Svenska
sv
Corsican
Corsu
co Kurdish (Northern)
Kurmancî
ku Tahitian
Reo Tahiti
ty
Croatian
Hrvatski
hr Kyrgyz
Кыргызча
ky Tajik
Тоҷикӣ
tg
Czech
Čeština
cs Lao
ລາວ
lo Tamil
தமிழ்
ta
Danish
Dansk
da Latin
Latina
la Tatar
татарча
tt
Dari
دری
prs Latvian
Latviešu
lv Telugu
తెలుగు
te
Dhivehi
ދިވެހި
dv Lingala
Lingála
ln Thai
ไทย
th
Dogri
डोगरी
doi Lithuanian
Lietuvių
lt Tibetan
བོད་ཡིག
bo
Dutch
Nederlands
nl Luganda
Luganda
lg Tigrinya
ትግርኛ
ti
Dzongkha
རྫོང་ཁ
dz Luxembourgish
Lëtzebuergesch
lb Tongan
Lea faka-Tonga
to
Eastern Mari
Олык марий
mhr Macedonian
Македонски
mk Tsonga
Xitsonga
ts
English
English
en Maithili
मैथिली
mai Turkish
Türkçe
tr
Esperanto
Esperanto
eo Malagasy
Malagasy
mg Turkmen
Türkmen
tk
Estonian
Eesti
et Malay
Bahasa Melayu
ms Twi
Twi
tw
Ewe
Eʋegbe
ee Malayalam
മലയാളം
ml Udmurt
Удмурт
udm
Faroese
Føroyskt
fo Maltese
Malti
mt Ukrainian
Українська
uk
Fijian
Vosa Vakaviti
fj Maori
Māori
mi Upper Sorbian
Hornjoserbšćina
hsb
Filipino
Filipino
tl Marathi
मराठी
mr Urdu
اُردُو
ur
Finnish
Suomi
fi Meiteilon
ꯃꯤꯇꯩꯂꯣꯟ
mni-Mtei Uyghur
ئۇيغۇر تىلى
ug
French
Français
fr Mizo
Mizo ṭawng
lus Uzbek
Oʻzbek tili
uz
French (Canadian)
Français canadien
fr-CA Mongolian
Монгол
mn Vietnamese
Tiếng Việt
vi
Frisian
Frysk
fy Mongolian (Traditional)
ᠮᠣᠩᠭᠣᠯ
mn-Mong Volapük
Volapük
vo
Galician
Galego
gl Myanmar
မြန်မာစာ
my Welsh
Cymraeg
cy
Georgian
ქართული
ka Nepali
नेपाली
ne Wolof
Wollof
wo
German
Deutsch
de Norwegian
Norsk
no Xhosa
isiXhosa
xh
Greek
Ελληνικά
el Occitan
Occitan
oc Yakut
Sakha
sah
Greenlandic
Kalaallisut
kl Odia
ଓଡ଼ିଆ
or Yiddish
ייִדיש
yi
Guarani
Avañe'ẽ
gn Oromo
Afaan Oromoo
om Yoruba
Yorùbá
yo
Gujarati
ગુજરાતી
gu Papiamento
Papiamentu
pap Yucatec Maya
Màaya T'àan
yua
Haitian Creole
Kreyòl Ayisyen
ht Pashto
پښتو
ps Zulu
isiZulu
zu
Hausa
Hausa
ha Persian
فارسی
fa
Hawaiian
ʻŌlelo Hawaiʻi
haw Polish
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.:

Reporting Bugs / Contributing

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

Licensing

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

translate-shell's People

Contributors

abhi18av avatar blechta avatar dunn avatar eisaev avatar firmart avatar joshstrobl avatar kyrios123 avatar levy9collision avatar m13253 avatar pabs3 avatar qwivan avatar self-perfection avatar soimort avatar szotsaki avatar vladimirsinitsin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

translate-shell's Issues

Man page not installed

There's no man page installed on my system. I installed via homebrew.

scotts-imac:~ lisa$ trans -m
groff: invalid option -- D
usage: groff [-abceghilpstvzCENRSUVXZ] [-Fdir] [-mname] [-Tdev] [-ffam]
       [-wname] [-Wname] [-Mdir] [-dcs] [-rcn] [-nnum] [-olist] [-Parg]
       [-Larg] [-Idir] [files...]
groff -h gives more help
sh: line 0: echo: write error: Broken pipe
scotts-imac:~ lisa$ 
scotts-imac:~ lisa$ man trans
No manual entry for trans
scotts-imac:man lisa$ ls /usr/local/share/man/man* | grep trans
scotts-imac:man lisa$ 

Send POST requests

For HTTP GET requests (which is being used now), encoded URIs will have a length limit, restricted by both web servers, proxies and clients (See this thread http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request). That is why we don't recommend translating very long texts -- they could fail if the server/proxy can't handle them correctly.

A POST request would solve this problem. (it seems Google Translate supports that as well)

Smarter arg parsing

On my shell I have to add backslashes to pass the language parameters e.g. trs \{=de\} overmorgen.

I guess trs =de overmorgen could be easily parsed as well. Or trs fr=ar demain, trs es saber.
All language codes are two letters and if someone wants to translate word that happens to be a language code they could fall back in the { syntax.

Google does browser sniffing, 403 on no User-Agent

Without a UA header:

$ curl -v "http://translate.google.com/translate_a/t?client=t&ie=UTF-8&oe=UTF-8&text=before&sl=en&tl=sv&hl=sv"                                                                                                                                                = 11:14:59 Tue 31
* Hostname was NOT found in DNS cache
*   Trying 216.58.209.110...
* Connected to translate.google.com (216.58.209.110) port 80 (#0)
> GET /translate_a/t?client=t&ie=UTF-8&oe=UTF-8&text=before&sl=en&tl=sv&hl=sv HTTP/1.1
> User-Agent: curl/7.37.1
> Host: translate.google.com
> Accept: */*
> Referer:
>
< HTTP/1.1 403 Forbidden
< X-Content-Type-Options: nosniff
< Date: Tue, 31 Mar 2015 09:15:43 GMT
* Server HTTP server (unknown) is not blacklisted
< Server: HTTP server (unknown)
< Cache-Control: private
< X-XSS-Protection: 1; mode=block
< Set-Cookie: PREF=ID=363e6de56a4b1b07:TM=1427793343:LM=1427793343:S=q7Yaoo05hm79JH_k; expires=Thu, 30-Mar-2017 09:15:43 GMT; path=/; domain=.google.com
< Alternate-Protocol: 80:quic,p=0.5
< Accept-Ranges: none
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
< Via: 1.1 aer01-mda2-dmz-wsa-4-mgmt.cisco.com:80 (Cisco-WSA/8.5.0-497)
< Connection: keep-alive
<
<!DOCTYPE html><html lang=en><meta charset=utf-8><meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"><title>Error 403 (Forbidden)!!1</title><style>*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/errors/logo_sm_2.png) no-repeat}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/errors/logo_sm_2_hr.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/errors/logo_sm_2_hr.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/errors/logo_sm_2_hr.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:55px;width:150px}</style><a href=//www.google.com/><span id=logo aria-label=Google></span></a><p><b>403.</b> <ins>That’s an error.</ins><p>Your client does not have permission to get URL <code>/translate_a/t?client=t&amp;ie=UTF-8&amp;oe=UTF-8&amp;text=before&amp;sl=en&amp;tl=sv&amp;hl=sv</code> from this server.  (Client IP address: 173.38.209.9)<br><br>


* Connection #0 to host translate.google.com left intact
  <ins>That’s all we know.</ins>

With a UA header:

  /Users/aneculau/bin as aneculau@ANECULAU-M-H01K
  master *$%> a38c2b3 8↑ origin/master
$ curl -v -A "tranlate-shell/0.8.22.5" "http://translate.google.com/translate_a/t?client=t&ie=UTF-8&oe=UTF-8&text=before&sl=en&tl=sv&hl=sv"                                                                                                                   = 11:15:44 Tue 31
* Hostname was NOT found in DNS cache
*   Trying 216.58.209.110...
* Connected to translate.google.com (216.58.209.110) port 80 (#0)
> GET /translate_a/t?client=t&ie=UTF-8&oe=UTF-8&text=before&sl=en&tl=sv&hl=sv HTTP/1.1
> User-Agent: tranlate-shell/0.8.22.5
> Host: translate.google.com
> Accept: */*
> Referer:
>
< HTTP/1.1 200 OK
< Pragma: no-cache
< Date: Tue, 31 Mar 2015 09:15:50 GMT
< Expires: Tue, 31 Mar 2015 09:15:50 GMT
< Cache-Control: private, max-age=600
< Content-Language: sv
< X-Content-Type-Options: nosniff
< Content-Disposition: attachment; filename="f.txt"
* Server HTTP server (unknown) is not blacklisted
< Server: HTTP server (unknown)
< X-XSS-Protection: 1; mode=block
< Set-Cookie: PREF=ID=8cc78e93d473970a:TM=1427793350:LM=1427793350:S=3qV6SmN9yFLCLdVV; expires=Thu, 30-Mar-2017 09:15:50 GMT; path=/; domain=.google.com
< Alternate-Protocol: 80:quic,p=0.5
< Accept-Ranges: none
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< Content-Type: text/javascript; charset=UTF-8
< Via: 1.1 aer01-mda2-dmz-wsa-4-mgmt.cisco.com:80 (Cisco-WSA/8.5.0-497)
< Connection: keep-alive
<
* Connection #0 to host translate.google.com left intact
[[["före","before","",""]],[["adverb",["före","innan","förut","förrän","förr"],[["före",["before","prior to","preparatory to","in front","ahead"],,0.44374731],["innan",["before"],,0.362176],["förut",["before","previously","heretofore","formerly","before then","pre-term"]],["förrän",["before"]],["förr",["before","sooner","formerly","once","aforetime","yore"]]],"before",4],["konjunktion",["före","innan","förr","förut","förrän","framför"],[["före",["before"],,0.44374731],["innan",["before"],,0.362176],["förr",["before"]],["förut",["before"]],["förrän",["before","than"]],["framför",["before"]]],"before",7],["preposition",["före","innan","inför","framför","framom","för"],[["före",["before","previous to","ahead of","in front of"],,0.44374731],["innan",["before","prior to"],,0.362176],["inför",["before","in front of","at","fore"],,0.03758125],["framför",["in front of","above","before","ahead of","rather than"]],["framom",["before","ahead of"]],["för",["for","of","To","before","from","about"]]],"before",5]],"en",,[["före",[1],true,false,649,0,1,0]],[["before",1,[["före",649,true,false],["innan",350,true,false],["innan du",0,true,false],["tidigare",0,true,false],["inför",0,true,false]],[[0,6]],"before"]],,,[],3]
`
``

Allow mpv instead of mplayer / mplayer2

mpv, an mplayer fork / rewrite, is under active development and used by more and more programs (SMPlayer, for example). It would be good to have it as a possible alternative instead of mplayer.

[WARNING] Your locale codeset (en_CA) is not UTF-8.

When I started "trans", I got:
[WARNING] Your locale codeset (en_CA) is not UTF-8.

Despite the fact that my locale is UTF-8:
shell ~ $ export|grep en_CA
declare -x GDM_LANG="en_CA"
declare -x LANG="en_CA.UTF-8"
declare -x LANGUAGE="en_CA"

The issue occurred because the "UTF-8" string is checked on LANGUAGE instead of LANG variable:
function initUserLang() {
UserLocale = ENVIRON["LANGUAGE"] ? ENVIRON["LANGUAGE"] :
(ENVIRON["LC_ALL"] ? ENVIRON["LC_ALL"] :
(ENVIRON["LANG"] ? ENVIRON["LANG"] : "en_US.UTF-8"))
if (tolower(UserLocale) !~ /utf-?8$/)
w("[WARNING] Your locale codeset (" UserLocale ") is not UTF-8.")
UserLang = parseLang(UserLocale)
}

A solution could be to check the language on all variable (LANGUAGE + LANG) and assume UTF-8 is present when one of them contains UTF-8 (in my case, It was LANG, instead of LANGUAGE).

Thank you in advance.

Bests regards,
Asher256

Terminal goes bold forever

When I use trans to translate anything to any language its output is in bold (as it's meant to be I guess). However, my terminal font remains bold and other commands, e.g. 'cat' is in bold too.
'ls' returns everything into its original state (perhaps that's because it works with fonts too)

OS: opensuse 13.2
Translate Shell 0.8.22.2
gawk (GNU Awk) 4.1.1
fribidi (GNU FriBidi) [NOT INSTALLED]
User Language English (English)

the phonetic reading of non-latin characters

Ok never mind this. I only read the manual, and not the front page here which explains this more extensively sorry

v@v-MS-7599:~$ trans :@zh -b 我试试
Wǒ shì shì

Hey, I'm not sure if I am doing something wrong, but I am not getting a phonetic reading in the output. Here's an example:

v@v-MS-7599:~$ trans 漢字
Chinese characters

Translations of 漢字
(日本語 ➔ English)
漢字(Chinese characters/Chinese character/Kanji character/Kanji/Kanji characters)

[noun]
Chinese characters
漢字

The chinese translation would have Hànzì and the japanese would have Kanji on that one. (Well you can guess the japanese reading from some of the transations)

Same result with -v and -b flags. I am running Ubuntu 14.04

v@v-MS-7599:~$ trans -V
Translate Shell 0.8.22

gawk (GNU Awk) 4.0.1
fribidi (GNU FriBidi) [NOT INSTALLED]
User Language English (English)

empty output

no idea if it's related to #44 (haven't checked the code)
but translations comes out empty now (after upgrading 22.5 to 23)

$ trans -t zh+ja word

────────────────────────────────────────────────────────────────

Use better table in README.md

┌─────┬───────────────┐  
│    │              │  
└────┴────────────────┘

gawk: cmd. line:181: fatal: attempt to use scalar parameter `array' as an array

Hi,

I hope you will be able to reproduce the following

$ trans es:de salir
gawk: cmd. line:181: fatal: attempt to use scalar parameter `array' as an array

If not, please contact me for further information.

Please peing me via mail if you might issue a new release to make sure I'll create a Debian package from it.

Kind regards

    Andreas.

Add HEAD for the Homebrew formula

gawk 4.1.2 broke 0.8.23 (#55), and the fix hasn't made into a release yet. Therefore, could you please add a HEAD to the Homebrew formula so that we may install the latest version without breaking out of brew? The formula could be like this: (By the way, latest develop doesn't really work on OS X, but that will be the subject of another issue)

require "formula"

class TranslateShell < Formula
  homepage "http://www.soimort.org/translate-shell"
  url "http://www.soimort.org/translate-shell/translate-shell.tar.gz"
  sha1 "f33287a1f0827b215514e2bd82671e03f0d908ce"
  version "0.8.23"

  head "https://github.com/soimort/translate-shell.git", :branch => "develop"

  depends_on 'fribidi' => :optional
  depends_on 'gawk'
  depends_on 'mplayer'
  depends_on 'rlwrap'

  def install
    if build.head?
      system "make"
      bin.install "build/trans"
      man1.install "man/trans.1"
    else
      bin.install "trans"
      man1.install "trans.1"
    end
  end
end

Cannot translate if first word contains "file"

$ trans "file"
gawk: cmd. line:1263: fatal: expression for `<' redirection has null string value

$ trans "file name"
gawk: cmd. line:1263: fatal: expression for `<' redirection has null string value

$ trans "filename"
gawk: cmd. line:1263: fatal: expression for `<' redirection has null string value

$ trans -b "a file"
파일 

If first word of context contains "file", error occur.

environment

Translate Shell 0.8.22.3

gawk (GNU Awk)        4.1.1
fribidi (GNU FriBidi) [NOT INSTALLED]
User Language         Korean (한국어)

Split and rejoin long lines

I need to use translate-shell to translate some thousand files, but some of them are supposed to have very long lines. I was thinking that the best way to handle this is splitting and later rejoining them.

So, I'd like to ask you if it is possible somehow to implement this in translate-shell, so other users might benefit from it!

Language name for NL is Nederlands, not Deutsch

When translating a Dutch word to French or Spanish the language name shown in the details is Deutsch (see output below) this is wrong, the correct name for the NL ISO code is Nederlands. It's correct when translating from Dutch to English or Hungarian though.

$ trans nl:fr hallo
bonjour

Translations of hallo
(Deutsch ➔ Français)
hallo(bonjour)

The correct output should be:

(Nederlands ➔ Français)

German and Dutch can be confusing, they are both different languages but their English and native names are confusing so here is a little reminder:

ISO English name Native name Spoken
DE German Deutsch in Germany
NL Dutch Nederlands in the Netherlands and Belgium

Install: cannot create regular file ‘/usr/local/share/man/man1/trans.1’: No such file or directory

Install from git failed for me because there isn't right directory for manual file by default. After creating directory "/usr/local/share/man/man1/" install was successful. I'm using openSUSE Tumbleweed.

Output:
[/temp] >git clone https://github.com/soimort/translate-shell
Cloning into 'translate-shell'...
remote: Counting objects: 2518, done.
remote: Compressing objects: 100% (59/59), done.
remote: Total 2518 (delta 23), reused 0 (delta 0), pack-reused 2459
Receiving objects: 100% (2518/2518), 1.53 MiB | 1.12 MiB/s, done.
Resolving deltas: 100% (1512/1512), done.
Checking connectivity... done.
[
/temp/translate-shell] >make
[OK] Task build completed.
[~/temp/translate-shell] >sudo make install
root's password:
cp: cannot create regular file ‘/usr/local/share/man/man1/trans.1’: No such file or directory
Makefile:33: recipe for target 'install' failed
make: *** [install] Error 1

85-23-29-218:[~] # cd /usr/local/share
85-23-29-218:/usr/local/share # mkdir man
85-23-29-218:/usr/local/share # cd man
85-23-29-218:/usr/local/share/man # mkdir man1
85-23-29-218:/usr/local/share/man # cd /home/[user]/temp/translate-shell
85-23-29-218:/home/[user]/temp/translate-shell # make install
[OK] translate-shell installed.

85-23-29-218:/home/[user]/temp/translate-shell # trans -V
Translate Shell 0.9.0.7-git:2eea418

platform Linux
gawk (GNU Awk) 4.1.3
fribidi (GNU FriBidi) 0.19.6
audio player mplayer
terminal pager less
terminal type xterm
user locale en_US.UTF-8 (English)
home language en
source language auto
target language en
proxy [NONE]
user-agent [NONE]
theme default
init file [NONE]

Translate Shell returns empty string

gif

Translate Shell used to work perfectly, but it suddenly stopped showing translations for whatever reason. Check out attached GIF. Any ideas?

OS X 10.10.2, iTerm 2 with zsh.

How do I know whether I have BSD awk or GNU awk?

Apologies for the silly question.

I'm on OS X. How do I tell which awk I have? awk doesn't accept -h or --help. The only info I can get is:

$ awk --version
awk version 20070501
$ which awk
/usr/bin/awk

Assuming I have BSD awk, is there any disadvantage to installing GNU awk?

Better support for non-gvim users

This is my first issue ever on github, so apologizes if I do this wrong.

I implemented the vim-hack, and it is working fine. However, I do not use gvim, but normal vim in the terminal. When I press -K vim goes to the terminal windows and shows me the translate rather than showing it inside vim at the bottom, as your nice example gif shows. However, when using gvim, it is working fine.
Any advice to get this working? :)

screenshot from 2014-03-13 17 33 56
screenshot from 2014-03-13 17 33 37

The two pictures shows an example. After I hit Enter, I return normally to vim.

Cheers,
Daniel

Please add support to HTTP proxy

I can not establish a direct connection to translate.google.com:80, so I need to use a HTTP proxy.

Could you please add support to HTTP proxy? Either by using $http_proxy or by specifying --proxy in command line.

By the way, is it difficult to use HTTPS instead of HTTP? I think it may be more secure.

Thanks.

UTF-8 check misses locales with `utf8` extension

trans always complains that my locale codeset is not UTF-8, which is wrong:
[WARNING] Your locale codeset (en_US.utf8) is not UTF-8. You have been warned.

echo $LANG outputs en_US.utf8. I have to admit that my LC_CTYPE environment variable is not set, but I don't think I have to, because setting LANG should be enough:

LANG
If this environment variable is defined, its value specifies the locale to use for all purposes except as overridden by the variables above.

The main problem is, that you are checking for some_LANG.utf-8 in Language.awk:529 but not for some_LANG.utf8.

I am using Arch Linux with Kernel release 3.17.4-1-ARCH.

FOSDEM '15

(this is a quick message for those who are attending FOSDEM this weekend; otherwise you can ignore it)
Hi all,

I will appear on this year's FOSDEM in Brussels, Belgium, between Saturday and Sunday (31 Jan - 1 Feb). Also at VUB for RMS's talk on Friday afternoon. If you will come by, have any questions regarding translate-shell (or other open source software I might be interested in), or just want to say hello and have some beer with me, feel free to drop me a line.

Cheers,
Mort

"Something went wrong" error

I just installed translate-shell via Homebrew and I'm getting this error every time I'm attempting to translate something.

Command entered

trans vorto

Actual output

[ERROR] Oops! Something went wrong and I can't translate it for you :(

Output of trans -V

Translate Shell       0.9.0.4-release

platform
gawk (GNU Awk)        4.1.3
fribidi (GNU FriBidi) 0.19.6
audio player          mplayer
terminal pager        less
terminal type         xterm-256color
user locale           en_US.UTF-8 (English)
home language         en
source language       auto
target language       en
theme                 default
init file             [NONE]

Report bugs to:       https://github.com/soimort/translate-shell/issues

I wish I could be more helpful, but the error message is not very descriptive. I'm running OS X 10.10.4, and I have all the latest dependencies installed.

[Fatal] trans broken

The old API seems to be no longer available there.

$ trans --debug lagom
'ontent='</BODY></HTML>
tokens[0]='</BODY></HTML>'
ast[0]='</BODY></HTML>'
$ curl -v -A "tranlate-shell/0.8.22.5" "http://translate.google.com/translate_a/t?client=t&ie=UTF-8&oe=UTF-8&text=lagom&sl=sv&tl=en&hl=en"
* About to connect() to translate.google.com port 80 (#0)
*   Trying 224.0.0.1...
* connected
* Connected to translate.google.com (224.0.0.1) port 80 (#0)
> GET /translate_a/t?client=t&ie=UTF-8&oe=UTF-8&text=lagom&sl=sv&tl=en&hl=en HTTP/1.1
> User-Agent: tranlate-shell/0.8.22.5
> Host: translate.google.com
> Accept: */*
> 
< HTTP/1.1 302 Found
< Location: http://ipv4.google.com/sorry/IndexRedirect?continue=http://translate.google.com/translate_a/t%3Fclient%3Dt%26ie%3DUTF-8%26oe%3DUTF-8%26text%3Dlagom%26sl%3Dsv%26tl%3Den%26hl%3Den&q=CGMSBGiDnlUYnJySqQUiGQDxp4NL5R76fQk_5cbxbAFswmvf3oK9pOM
< Date: Wed, 08 Apr 2015 02:10:37 GMT
< Pragma: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Content-Type: text/html; charset=UTF-8
< Server: HTTP server (unknown)
< Content-Length: 436
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Alternate-Protocol: 80:quic,p=0.5
< 
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://ipv4.google.com/sorry/IndexRedirect?continue=http://translate.google.com/translate_a/t%3Fclient%3Dt%26ie%3DUTF-8%26oe%3DUTF-8%26text%3Dlagom%26sl%3Dsv%26tl%3Den%26hl%3Den&amp;q=CGMSBGiDnlUYnJySqQUiGQDxp4NL5R76fQk_5cbxbAFswmvf3oK9pOM">here</A>.
</BODY></HTML>
* Connection #0 to host translate.google.com left intact
* Closing connection #0

A proper fix is to implement #30, using the working one.

Installed without gnu awk.. how to uninstall?

I installed this without installing GNU Awk on my mac. How do i go about doing an uninstall? I installed coretools (Contains gawk) using homebrew to try and remedy the problem but i still get this error:

env: gawk: No such file or directory

tokenize() too slow

This mainly affects theme loading, and parsing of large JSON data.

When the user has a large theme file (> 2k bytes), trans suffers from slow startup time.

With a theme:

0.43s user 0.03s system 91% cpu 0.503 total

Without a theme:

0.11s user 0.04s system 78% cpu 0.182 total

Not working

Does not work for me, it just waits forever after entering the command.

Can it be that I'm behing a proxy? Should it work behind a proxy?

Daily limits?

Are there any daily limits? I've tried to translate a long file and it will translate only a portion of it. Then I try running 'trs' from command line and Google returns blank responses to any requests. I wait 24 hours and then it works again. Any advice?

[Configuration] a more common and appropriate path

Are you considering to put ~/.translate-shell/init.trans under ~/config/translate-shell/ which is a more general and common way of where configuration files are placed (on some Linux distro, e.g., Ubuntu)

Or a prioritize it as below

  1. .trans
  2. ~/config/translate-shell/init.trans
  3. ~/.translate-shell/init.trans
  4. /etc/translate-shell (not recommended)

[request] Would you please add an option to diable the ANSI escapings ?

In Q&A I found out the TERM=dumb trans ... method.
However I want to use it inside golden-dict as a user-defined dictionary program, which I believe, don't allow me to change the environment variable...

And it feels strange to me if I start golden-dict with TERM=dumb golden-dict ...

Right-to-left languages support

For now translation to right-to-left languages (hebrew for example) is unreadable because it's printed from left to right.
Of course I can use 'rev'

trs {=he} 'Israel' | rev

But it isn't elegant solution.

$TRANS_PROGRAM has grown too large for OS X

For the latest commits on the develop branch, I get the following error on OS X 10.10.3 with bash 4.3.33(1) installed via Homebrew:

line 3449: /usr/local/bin/gawk: Argument list too long

After a quick bisect, I found the culprit to be 467a56d:

> git checkout 467a56d  # develop~7
> make &>/dev/null && build/trans -b hello
build/trans: line 3449: /usr/local/bin/gawk: Argument list too long
> sed -nr "/'EOF'$/,/^EOF/{ /'EOF'$/b; /^EOF/b; p }" build/trans | wc -c  # get the length in bytes of $TRANS_PROGRAM
134262
> git checkout HEAD~1  # develop~8
> make &>/dev/null && build/trans -b hello
hello
> sed -nr "/'EOF'$/,/^EOF/{ /'EOF'$/b; /^EOF/b; p }" build/trans | wc -c
133861

The problem appears to be along the line of MAX_ARG_STRLEN (not sure about the OS X equivalent), limiting the max length of a single argument, which was once 2^17=131072 on Linux, but apparently the kernel moved on since I couldn't reproduce the bug on Ubuntu 15.04. The field-tested limit seems to be between 133861 and 134262, which is a little bit mysterious since 131072 is smaller than both. (Did I forget some heredoc quoting rule? Probably). At any rate, there's clearly a limit on the length of a single argument on OS X around 2^17, and $TRANS_PROGRAM is on the edge of exceeding it.

Cannot Install

I'm getting this error when I try to install the stable version

$ make install 
gawk: build.awk:3: error: can't open source file `include/Commons' for reading (No such file or directory)
make: *** [trans] Error 1

I have gawk version 4.0.1 in a new Ubuntu Gnome 14.04 installation.

The include folder is there, as it is the Commons.awk file inside it.

Note: I don't know (g)awk

[Fatal] Broken on gawk 4.1.2

The new release of gawk (4.1.2) broke a lot of shit, it seems...

translate-shell git:(stable) ./translate -V
gawk: In file included from translate.awk:40:
gawk: include/Main:278:         match(ARGV[pos], /^[{([]?([[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?)?)[})\]]?$/, group)
gawk: include/Main:278:                           ^ unterminated regexp
gawk: In file included from translate.awk:40:
gawk: include/Main:279:         match(ARGV[pos], /^[{([]?([[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?)?)[})\]]?$/, group)
gawk: include/Main:279:                                                                                                                                                                                                                                                             ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:279:         if (RSTART) {
gawk: include/Main:279:                     ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:280:             if (group[1]) Option["sl"] = group[1]
gawk: include/Main:280:                                        ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:281:             if (group[1]) Option["sl"] = group[1]
gawk: include/Main:281:                                                  ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:282:             if (group[4]) split(group[4], Option["tl"], "+")
gawk: include/Main:282:                                                             ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:287:         match(ARGV[pos], /^--$/)
gawk: include/Main:287:                                 ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:287:         if (RSTART) {
gawk: include/Main:287:                     ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:297:     postInit()
gawk: include/Main:297:               ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:298:     if (Option["interactive"] && !Option["no-rlwrap"]) {
gawk: include/Main:298:                                                        ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:301:         initRlwrap() # initialize Rlwrap
gawk: include/Main:301:                      ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:302:         if (Rlwrap && (ENVIRON["TRANS_PROGRAM"] || fileExists(EntryPoint))) {
gawk: include/Main:302:                                                                             ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:307:                 " -no-rlwrap" # be careful - never fork Rlwrap recursively!
gawk: include/Main:307:                               ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:307:             for (i = 1; i < length(ARGV); i++)
gawk: include/Main:307:                       ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:307:             for (i = 1; i < length(ARGV); i++)
gawk: include/Main:307:                                         ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:308:             for (i = 1; i < length(ARGV); i++)
gawk: include/Main:308:                                               ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:309:                 if (ARGV[i])
gawk: include/Main:309:                             ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:310:                     command = command " " parameterize(ARGV[i])
gawk: include/Main:310:                                                                ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:312:             if (!system(command))
gawk: include/Main:312:                                  ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:318:     } else if (!Option["interactive"] && !Option["no-rlwrap"] && Option["emacs"]) {
gawk: include/Main:318:                                                                                   ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:321:         Emacs = "emacs"
gawk: include/Main:321:                        ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:322:         if (ENVIRON["TRANS_PROGRAM"] || fileExists(EntryPoint)) {
gawk: include/Main:322:                                                                 ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:324:             params = ""
gawk: include/Main:324:                        ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:324:             for (i = 1; i < length(ARGV); i++)
gawk: include/Main:324:                       ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:324:             for (i = 1; i < length(ARGV); i++)
gawk: include/Main:324:                                         ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:325:             for (i = 1; i < length(ARGV); i++)
gawk: include/Main:325:                                               ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:326:                 if (ARGV[i])
gawk: include/Main:326:                             ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:327:                     params = params " " (parameterize(ARGV[i], "\""))
gawk: include/Main:327:                                                                      ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:327:             if (ENVIRON["TRANS_PROGRAM"]) {
gawk: include/Main:327:                                           ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:332:                     "(command-execute 'shell) (rename-buffer \"" Name "\"))"
gawk: include/Main:332:                                                                             ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:336:                     "(command-execute 'shell) (rename-buffer \"" Name "\"))"
gawk: include/Main:336:                                                                             ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:338:             command = Emacs " --eval " parameterize(el)
gawk: include/Main:338:                                                        ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:340:             if (!system(command))
gawk: include/Main:340:                                  ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:343:                 Option["interactive"] = 1 # skip
gawk: include/Main:343:                                           ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:345:             Option["interactive"] = 1 # skip
gawk: include/Main:345:                                       ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:347:     if (Option["play"]) {
gawk: include/Main:347:                         ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:349:         if (!Option["player"]) {
gawk: include/Main:349:                                ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:351:             initAudioPlayer()
gawk: include/Main:351:                              ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:352:             Option["player"] = AudioPlayer ? AudioPlayer : Option["player"]
gawk: include/Main:352:                                                                            ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:353:             if (!Option["player"])
gawk: include/Main:353:                                   ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:354:                 initSpeechSynthesizer()
gawk: include/Main:354:                                        ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:356:         if (!Option["player"] && !SpeechSynthesizer) {
gawk: include/Main:356:                                                      ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:358:             w("[WARNING] No available audio player or speech synthesizer is found.")
gawk: include/Main:358:                                                                                     ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:359:             Option["play"] = 0
gawk: include/Main:359:                               ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:362:     if (Option["interactive"]) {
gawk: include/Main:362:                                ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:364:         print AnsiCode["bold"] AnsiCode[tolower(Option["prompt-color"])] getVersion() AnsiCode[0] > "/dev/stderr"
gawk: include/Main:364:                                                                                                                  ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:365:         print AnsiCode[tolower(Option["prompt-color"])] "(:q to quit)" AnsiCode[0] > "/dev/stderr"
gawk: include/Main:365:                                                                                                   ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:368:     if (!Option["browser"]) {
gawk: include/Main:368:                             ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:370:         "xdg-mime query default text/html 2>/dev/null" |& getline Option["browser"]
gawk: include/Main:370:                                                                                    ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:371:         match(Option["browser"], "(.*).desktop$", group)
gawk: include/Main:371:                                                         ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:372:         Option["browser"] = group[1]
gawk: include/Main:372:                                     ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:376:     if (Option["no-ansi"])
gawk: include/Main:376:                           ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:378:     if (pos < ARGC) {
gawk: include/Main:378:                     ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:382:         for (i = pos; i < ARGC; i++) {
gawk: include/Main:382:                     ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:382:         for (i = pos; i < ARGC; i++) {
gawk: include/Main:382:                               ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:382:         for (i = pos; i < ARGC; i++) {
gawk: include/Main:382:                                      ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:385:             if (Option["verbose"] && i > pos)
gawk: include/Main:385:                                              ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:386:                 print replicate("═", Option["width"])
gawk: include/Main:386:                                                        ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:388:             translate(ARGV[i], 1) # inline mode
gawk: include/Main:388:                                   ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:395:         if (!Option["input"]) Option["input"] = "/dev/stdin"
gawk: include/Main:395:                                               ^ syntax error
gawk: In file included from translate.awk:40:
gawk: include/Main:400:     if (Option["input"])
gawk: include/Main:400:                         ^ unexpected newline or end of string
gawk: In file included from translate.awk:40:
gawk: include/Main:401:         translateMain()
gawk: include/Main:401:                        ^ unexpected newline or end of string

Empty output for any input

Hi,
Thanks for the good work. I was desperately looking for something like this. However, when I installed it via apt-get on Ubuntu 15.04, I got an empty output for any input I typed (It seems to be a blank line). No message or error or,...
Do you have any idea what should I do? I tested installing using the wget method but again the same result.
Thanks
Best

Offline language files?

I'd like to do a lot of translating and fear that Google wouldn't allow such traffic.

Therefore I am wondering if it's possible to install the language files locally, such that one doesn't need to access Google's translation service online?

Make test not working on OS X due to readline differences

trs works fine when I run it myself, but when I run make test, I get this:

 `./translate 忍者` = 'Ninja' ]
readlink: illegal option -- f
usage: readlink [-n] [file ...]
[ `./translate {zh=} 忍者` = 'Ninja' ]
readlink: illegal option -- f
usage: readlink [-n] [file ...]
[ `./translate {=fr} 忍者` = 'Ninja' ]
readlink: illegal option -- f
usage: readlink [-n] [file ...]
[ `./translate {ja=@ja} 忍者` = 'Ninja' ]
readlink: illegal option -- f
usage: readlink [-n] [file ...]
[ `./translate {zh=ja} 忍者` = '忍者' ]
readlink: illegal option -- f
usage: readlink [-n] [file ...]

A little search led me to this topic - BSD readlink is quite different to Linux readlink :( There are several solutions there, but none are especially pretty.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.