NAME
translate - translate a text or web page
SYNOPSIS
- translate {-? | -v |
--list-services}
- translate [-s services]
[-f lang] [-t lang] {-l}
- translate [-s services]
[-f lang] [-t lang] {http_url |
https_url}
- translate [-s services]
[-f lang] [-t lang]
[--max-threads=n] [--max-retries=n]
[file]
DESCRIPTION
translate translates a text or web page.
- If the first synopsis form is used, translate prints a
quick help, the version information or the list of available
translation services to standard output.
If the second synopsis form is used, translate prints the
list of available language pairs to standard output.
If the third synopsis form is used, translate translates
the web page pointed to by http_url or https_url, and
prints the URL of the translated web page to standard output
(http_url must be a string starting with http://, and https_url must be a string
starting with https://).
If the fourth synopsis form is used, translate translates
the text contained in file, and prints the translation to
standard output (if file is omitted or given as a single
dash, standard input is used instead).
OPTIONS
- -?, --help
- Prints a quick help to standard output.
- -v, --version
- Prints version information to standard output.
- --list-services
- Lists the available translation services.
- -s services, --services=services
- Specifies the translation services to use. The services
argument must be a comma-separated list of service names (default
value: all the available services).
The list of services determines the available language pairs.
The order of the list is important, as libtranslate iterates over
the list until the requested translation can be performed.
- -l, --list-pairs
- Lists the available language pairs.
The -f and -t options can be used to specify a
source and/or destination language filter. If neither -f nor
-t is specified, all the pairs are listed.
- -f lang, --from=lang
- Specifies the source language of a translation. The lang
argument must be a RFC 3066 language tag such as en or zh-TW
(default value: see Language Selection).
- -t lang, --to=lang
- Specifies the destination language of a translation. The
lang argument must be a RFC 3066 language tag such as en or
zh-TW (default value: see Language Selection).
- --max-threads=n
- Specifies the maximum number of concurrent threads to use for
translating text (default value: 8).
- --max-retries=n
- Specifies the maximum number of retries per text chunk (default
value: 3).
LANGUAGE SELECTION
Definitions: in this section, default_from is defined as
the contents of the environment variable
TRANSLATE_DEFAULT_FROM, or, if that variable is not set, en;
default_to is defined as the contents of the environment
variable TRANSLATE_DEFAULT_TO, or, if that variable is not
set, fr.
If the source language is not specified, it defaults to
default_from, or, if the destination language is equal to
default_from, default_to.
If the destination language is not specified, it defaults to
default_to, or, if the source language is equal to
default_to, default_from.
CHARACTER SET HANDLING
Internally, libtranslate uses the UTF-8 encoding.
If the input text is not encoded in UTF-8, translate
assumes it is encoded in the character set of the current locale,
and attempts to convert it to UTF-8. If the conversion fails,
translate exits with an error.
The output text is converted to the character set of the current
locale before printing.
EXAMPLES
In the following examples, it is assumed that
TRANSLATE_DEFAULT_FROM is set to es and that
TRANSLATE_DEFAULT_TO is set to de.
- translate -f fr -l
- Lists all the available language pairs where the source
language is French.
- translate document1
- Translates the contents of the file document1 from Spanish to
German and prints the result to standard output.
- translate -s babelfish,freetranslation document1
- Translates the contents of the file document1 from Spanish to
German, only using the Babel Fish and FreeTranslation services, and
prints the result to standard output.
- translate -f de document1
- Translates the contents of the file document1 from German to
Spanish and prints the result to standard output.
- echo "Le problème est résolu."
| translate -f fr -t en
- Translates the text given on standard input from French to
English and prints the result to standard output.
- translate -t en http://www.freebsd.org/es/index.html
- Translates the web page pointed to by http://www.freebsd.org/es/index.html
from Spanish to English and prints an URL pointing to the result to
standard output.
DIAGNOSTICS
The translate utility exits with a status of 0 on
success, and >0 if an error occurs.
ENVIRONMENT
The following environment variables affect the execution of
translate:
- HTTP_PROXY
- The URL of the proxy to use for HTTP requests.
- http_proxy
- Same as HTTP_PROXY, for compatibility.
- TRANSLATE_DEFAULT_FROM
- The default source language (see Language Selection).
- TRANSLATE_DEFAULT_TO
- The default destination language (see Language
Selection).
SEE ALSO
The libtranslate Reference Manual
AUTHOR
Jean-Yves Lefort.