Scroll to navigation

TRANS(1) TRANS(1)

NAME

trans - Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.

SYNOPSIS

trans [OPTIONS] [SOURCE]:[TARGETS] [TEXT]...

DESCRIPTION

This tool translates text into any language from the command-line, using a translation engine such as Google Translate, Bing Translator and Yandex.Translate.

Each argument which is not a valid option is treated as TEXT to be translated.

If neither TEXT nor the input file is specified by command-line arguments, the program will read and translate from standard input.

OPTIONS

Information options

Print version and exit.
Print help message and exit.
Show man page and exit.
Print reference table of all supported languages and codes, and exit. Names of languages are displayed in their endonyms (language name in the language itself).
Print reference table of all supported languages and codes, and exit. Names of languages are displayed in English.
List available translation engines and exit.
List all supported languages (in endonyms) and exit.
List all supported languages (in English names) and exit.
List all supported codes and exit.
List all supported languages (endonyms and English names) and codes, and exit.
Print details of languages and exit. When specifying two or more language codes, concatenate them by plus sign "+".
Check for upgrade of this program.

Translator options

Specify the translation engine to use. (default: auto)

Display options

Verbose mode.

Show the original text and its most relevant translation, then its phonetic notation (if any), then its alternative translations (if any) or its definition in the dictionary (if it is a word).

This option is unnecessary in most cases since verbose mode is enabled by default.

Brief mode.

Show the most relevant translation or its phonetic notation only.

Dictionary mode.

Show the definition of the original word in the dictionary.

Language identification.

Show the identified language of the original text.

Show original text or not. (default: yes)
Show phonetic notation of original text or not. (default: yes)
Show translation or not. (default: yes)
Show phonetic notation of translation or not. (default: yes)
Show prompt message or not. (default: yes)
Show source and target languages or not. (default: yes)
Show dictionary entry of original text or not. (default: no)

This option is enabled in dictionary mode.

Show dictionary entry of translation or not. (default: yes)
Show alternative translations or not. (default: yes)
Specify the screen width for padding.

This option overrides the setting of environment variable $COLUMNS.

Specify the size of indent (number of spaces). (default: 4)
Specify the theme to use. (default: default)
Do not use any other theme than default.
Do not use ANSI escape codes.
Do not autocorrect. (if defaulted by the translation engine)
Do not convert bidirectional texts.
Always convert bidirectional texts.
Do not write warning messages to stderr.
Print raw API response instead.

Audio options

Listen to the translation.

You must have at least one of the supported audio players (mplayer, mpv or mpg123) installed to stream from Google Text-to-Speech engine. Otherwise, a local speech synthesizer may be used instead (say on macOS, espeak on Linux or other platforms).

Listen to the original text.
Specify the narrator, and listen to the translation.

Common values for this option are male and female.

Specify the audio player to use, and listen to the translation.

Option -play will try to use mplayer, mpv or mpg123 by default, since these players are known to work for streaming URLs. Not all command-line audio players can work this way. Use this option only when you have your own preference.

This option overrides the setting of environment variable $PLAYER.

Do not listen to the translation.
Do not translate anything when using -speak.
Download the audio to the current directory.
Download the audio to the specified file.

Terminal paging and browsing options

View the translation in a terminal pager (less, more or most).
Specify the terminal pager to use, and view the translation.

This option overrides the setting of environment variable $PAGER.

Do not view the translation in a terminal pager.
Specify the web browser to use.

This option overrides the setting of environment variable $BROWSER.

Do not open the web browser.

Networking options

Use HTTP proxy on given port.

This option overrides the setting of environment variables $HTTP_PROXY and $http_proxy.

Specify the User-Agent to identify as.

This option overrides the setting of environment variables $USER_AGENT.

-4, -ipv4, -inet4-only
Connect only to IPv4 addresses.
-6, -ipv6, -inet6-only
Connect only to IPv6 addresses.

Interactive shell options

Start an interactive shell, invoking rlwrap whenever possible (unless -no-rlwrap is specified).
Start the GNU Emacs front-end for an interactive shell.

This option does not need to, and cannot be used along with -I or -no-rlwrap.

Do not invoke rlwrap when starting an interactive shell.

This option is useful when your terminal type is not supported by rlwrap (e.g. emacs).

I/O options

Specify the input file.

Source text to be translated will be read from the input file, instead of standard input.

Specify the output file.

Translations will be written to the output file, instead of standard output.

Language preference options

Specify your home language (the language you would like to see for displaying prompt messages in the translation).

This option affects only the display in verbose mode (anything other than source language and target language will be displayed in your home language). This option has no effect in brief mode.

This option is optional. When its setting is omitted, English will be used.

This option overrides the setting of environment variables $LC_ALL, $LANG, and $HOST_LANG.

Specify the source language(s) (the language(s) of original text). When specifying two or more language codes, concatenate them by plus sign "+".

This option is optional. When its setting is omitted, the language of original text will be identified automatically (with a possibility of misidentification).

This option overrides the setting of environment variable $SOURCE_LANG.

Specify the target language(s) (the language(s) of translated text). When specifying two or more language codes, concatenate them by plus sign "+".

This option is optional. When its setting is omitted, everything will be translated into English.

This option overrides the setting of environment variables $LC_ALL, $LANG, and $TARGET_LANG.

[SOURCE]:[TARGETS]
A simpler, alternative way to specify the source language and target language(s) is to use a shortcut formatted string:
SOURCE-CODE:TARGET-CODE
SOURCE-CODE:TARGET-CODE1+TARGET-CODE2+...
SOURCE-CODE=TARGET-CODE
SOURCE-CODE=TARGET-CODE1+TARGET-CODE2+...

Delimiter ":" and "=" can be used interchangeably.

Either SOURCE or TARGETS may be omitted, but the delimiter character must be kept.

Text preprocessing options

Treat all arguments as one single sentence.

Other options

Do not load any initialization script.
--
End-of-options.

All arguments after this option are treated as TEXT to be translated.

EXIT STATUS

0
Successful translation.
1
Error.

ENVIRONMENT

Equivalent to option setting -pager.
Equivalent to option setting -browser.
Equivalent to option setting -player.
Equivalent to option setting -proxy.
Equivalent to option setting -user-agent.
Equivalent to option setting -host.
Equivalent to option setting -source.
Equivalent to option setting -target.

FILES

/etc/translate-shell
Initialization script. (system-wide)
$HOME/.translate-shell/init.trans
Initialization script. (user-specific)
$XDG_CONFIG_HOME/translate-shell/init.trans
Initialization script. (user-specific)
./.trans
Initialization script. (current directory)

FURTHER DOCUMENTATION

<https://github.com/soimort/translate-shell/wiki>

REPORTING BUGS

<https://github.com/soimort/translate-shell/issues>

AUTHORS

Mort Yao <soi@mort.ninja>.

2023-02-08 0.9.7.1