mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-25 00:50:15 +08:00
PRF:20171130 Translate Shell – A Tool To Use Google Translate From Command Line In Linux.md
@lujun9972 译者没署名,我找了半天 /cry
This commit is contained in:
parent
5154aec58e
commit
f6d529c21c
@ -1,68 +1,65 @@
|
|||||||
Translate Shell: 一款在 Linux 命令行中使用 Google Translate的工具
|
Translate Shell :一款在 Linux 命令行中使用谷歌翻译的工具
|
||||||
============================================================
|
============================================================
|
||||||
|
|
||||||
我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用.
|
我对 CLI 应用非常感兴趣,因此热衷于使用并分享 CLI 应用。 我之所以更喜欢 CLI 很大原因是因为我在大多数的时候都使用的是字符界面(black screen),已经习惯了使用 CLI 应用而不是 GUI 应用。
|
||||||
|
|
||||||
我写过很多关于 CLI 应用的文章。 最近我发现了一些 google 的 CLI 工具,像 “Google Translator”, “Google Calendar”, 和 “Google Contacts”。 这里,我想在给大家分享一下。
|
我写过很多关于 CLI 应用的文章。 最近我发现了一些谷歌的 CLI 工具,像 “Google Translator”、“Google Calendar” 和 “Google Contacts”。 这里,我想在给大家分享一下。
|
||||||
|
|
||||||
今天我们要介绍的是 “Google Translator” 工具。 由于母语是泰米尔语,我在一天内用了很多次才理解了它的意义。
|
今天我们要介绍的是 “Google Translator” 工具。 由于我的母语是泰米尔语,我在一天内用了很多次才理解了它的意义。
|
||||||
|
|
||||||
`Google translate` 为其他语系的人们所广泛使用。
|
谷歌翻译为其它语系的人们所广泛使用。
|
||||||
|
|
||||||
### 什么是 Translate Shell
|
### 什么是 Translate Shell
|
||||||
|
|
||||||
[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助 `Google Translate`(默认), `Bing Translator`, `Yandex.Translate` 以及 `Apertium` 来翻译的命令行翻译器。
|
[Translate Shell][2] (之前叫做 Google Translate CLI) 是一款借助谷歌翻译(默认)、必应翻译、Yandex.Translate 以及 Apertium 来翻译的命令行翻译器。它让你可以在终端访问这些翻译引擎。 Translate Shell 在大多数 Linux 发行版中都能使用。
|
||||||
它让你可以在终端访问这些翻译引擎. `Translate Shell` 在大多数Linux发行版中都能使用。
|
|
||||||
|
|
||||||
### 如何安装 Translate Shell
|
### 如何安装 Translate Shell
|
||||||
|
|
||||||
有三种方法安装 `Translate Shell`。
|
有三种方法安装 Translate Shell。
|
||||||
|
|
||||||
* 下载自包含的可执行文件
|
* 下载自包含的可执行文件
|
||||||
|
|
||||||
* 手工安装
|
* 手工安装
|
||||||
|
* 通过包管理器安装
|
||||||
|
|
||||||
* 通过包挂力气安装
|
#### 方法 1 : 下载自包含的可执行文件
|
||||||
|
|
||||||
#### 方法-1 : 下载自包含的可执行文件
|
|
||||||
|
|
||||||
下载自包含的可执行文件放到 `/usr/bin` 目录中。
|
下载自包含的可执行文件放到 `/usr/bin` 目录中。
|
||||||
|
|
||||||
```shell
|
```
|
||||||
$ wget git.io/trans
|
$ wget git.io/trans
|
||||||
$ chmod +x ./trans
|
$ chmod +x ./trans
|
||||||
$ sudo mv trans /usr/bin/
|
$ sudo mv trans /usr/bin/
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 方法-2 : 手工安装
|
#### 方法 2 : 手工安装
|
||||||
|
|
||||||
克隆 `Translate Shell` github 仓库然后手工编译。
|
克隆 Translate Shell 的 GitHub 仓库然后手工编译。
|
||||||
|
|
||||||
```shell
|
```
|
||||||
$ git clone https://github.com/soimort/translate-shell && cd translate-shell
|
$ git clone https://github.com/soimort/translate-shell && cd translate-shell
|
||||||
$ make
|
$ make
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 方法-3 : Via Package Manager
|
#### 方法 3 : 通过包管理器
|
||||||
|
|
||||||
有些发行版的官方仓库中包含了 `Translate Shell`,可以通过包管理器来安装。
|
有些发行版的官方仓库中包含了 Translate Shell,可以通过包管理器来安装。
|
||||||
|
|
||||||
对于 Debian/Ubuntu, 使用 [APT-GET Command][3] 或者 [APT Command][4]来安装。
|
对于 Debian/Ubuntu, 使用 [APT-GET 命令][3] 或者 [APT 命令][4]来安装。
|
||||||
|
|
||||||
```shell
|
```
|
||||||
$ sudo apt-get install translate-shell
|
$ sudo apt-get install translate-shell
|
||||||
```
|
```
|
||||||
|
|
||||||
对于 Fedora, 使用 [DNF Command][5] 来安装。
|
对于 Fedora, 使用 [DNF 命令][5] 来安装。
|
||||||
|
|
||||||
```shell
|
```
|
||||||
$ sudo dnf install translate-shell
|
$ sudo dnf install translate-shell
|
||||||
```
|
```
|
||||||
|
|
||||||
对于基于 Arch Linux 的系统, 使用 [Yaourt Command][6] 或 [Packer Command][7] 来从 AUR 仓库中安装。
|
对于基于 Arch Linux 的系统, 使用 [Yaourt 命令][6] 或 [Packer 明快][7] 来从 AUR 仓库中安装。
|
||||||
|
|
||||||
```shell
|
```
|
||||||
$ yaourt -S translate-shell
|
$ yaourt -S translate-shell
|
||||||
or
|
or
|
||||||
$ packer -S translate-shell
|
$ packer -S translate-shell
|
||||||
@ -70,7 +67,7 @@ $ packer -S translate-shell
|
|||||||
|
|
||||||
### 如何使用 Translate Shell
|
### 如何使用 Translate Shell
|
||||||
|
|
||||||
安装好后,打开终端闭关输入下面命令。 `Google Translate` 会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。
|
安装好后,打开终端闭关输入下面命令。 谷歌翻译会自动探测源文本是哪种语言,并且在默认情况下将之翻译成你的 `locale` 所对应的语言。
|
||||||
|
|
||||||
```
|
```
|
||||||
$ trans [Words]
|
$ trans [Words]
|
||||||
@ -119,7 +116,7 @@ thanks
|
|||||||
நன்றி
|
நன்றி
|
||||||
```
|
```
|
||||||
|
|
||||||
要将一个单词翻译到多个语种可以使用下面命令(本例中, 我将单词翻译成泰米尔语以及印地语)。
|
要将一个单词翻译到多个语种可以使用下面命令(本例中,我将单词翻译成泰米尔语以及印地语)。
|
||||||
|
|
||||||
```
|
```
|
||||||
$ trans :ta+hi thanks
|
$ trans :ta+hi thanks
|
||||||
@ -172,7 +169,7 @@ what is going on your life?
|
|||||||
உங்கள் வாழ்க்கையில் என்ன நடக்கிறது?
|
உங்கள் வாழ்க்கையில் என்ன நடக்கிறது?
|
||||||
```
|
```
|
||||||
|
|
||||||
下面命令独立地翻译各个单词。
|
下面命令单独地翻译各个单词。
|
||||||
|
|
||||||
```
|
```
|
||||||
$ trans :ta curios happy
|
$ trans :ta curios happy
|
||||||
@ -208,14 +205,14 @@ happy
|
|||||||
சந்தோஷமாக, மகிழ்ச்சி, இனிய, சந்தோஷமா
|
சந்தோஷமாக, மகிழ்ச்சி, இனிய, சந்தோஷமா
|
||||||
```
|
```
|
||||||
|
|
||||||
简洁模式: 默认情况下,`Translate Shell` 尽可能多的显示翻译信息. 如果你希望只显示简要信息,只需要加上`-b`选项。
|
简洁模式:默认情况下,Translate Shell 尽可能多的显示翻译信息。如果你希望只显示简要信息,只需要加上 `-b`选项。
|
||||||
|
|
||||||
```
|
```
|
||||||
$ trans -b :ta thanks
|
$ trans -b :ta thanks
|
||||||
நன்றி
|
நன்றி
|
||||||
```
|
```
|
||||||
|
|
||||||
字典模式: 加上 `-d` 可以把 `Translate Shell` 当成字典来用.
|
字典模式:加上 `-d` 可以把 Translate Shell 当成字典来用。
|
||||||
|
|
||||||
```
|
```
|
||||||
$ trans -d :en thanks
|
$ trans -d :en thanks
|
||||||
@ -294,14 +291,14 @@ See also
|
|||||||
Thanks!, thank, many thanks, thanks to, thanks to you, special thanks, give thanks, thousand thanks, Many thanks!, render thanks, heartfelt thanks, thanks to this
|
Thanks!, thank, many thanks, thanks to, thanks to you, special thanks, give thanks, thousand thanks, Many thanks!, render thanks, heartfelt thanks, thanks to this
|
||||||
```
|
```
|
||||||
|
|
||||||
使用下面格式可以使用 `Translate Shell` 来翻译文件。
|
使用下面格式可以使用 Translate Shell 来翻译文件。
|
||||||
|
|
||||||
```shell
|
```
|
||||||
$ trans :ta file:///home/magi/gtrans.txt
|
$ trans :ta file:///home/magi/gtrans.txt
|
||||||
உங்கள் வாழ்க்கையில் என்ன நடக்கிறது?
|
உங்கள் வாழ்க்கையில் என்ன நடக்கிறது?
|
||||||
```
|
```
|
||||||
|
|
||||||
下面命令可以让 `Translate Shell` 进入交互模式. 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。
|
下面命令可以让 Translate Shell 进入交互模式。 在进入交互模式之前你需要明确指定源语言和目标语言。本例中,我将英文单词翻译成泰米尔语。
|
||||||
|
|
||||||
```
|
```
|
||||||
$ trans -shell en:ta thanks
|
$ trans -shell en:ta thanks
|
||||||
@ -324,13 +321,14 @@ thanks
|
|||||||
நன்றி
|
நன்றி
|
||||||
```
|
```
|
||||||
|
|
||||||
想知道语言代码,可以执行下面语言。
|
想知道语言代码,可以执行下面命令。
|
||||||
|
|
||||||
```shell
|
```
|
||||||
$ trans -R
|
$ trans -R
|
||||||
```
|
```
|
||||||
或者
|
或者
|
||||||
```shell
|
|
||||||
|
```
|
||||||
$ trans -T
|
$ trans -T
|
||||||
┌───────────────────────┬───────────────────────┬───────────────────────┐
|
┌───────────────────────┬───────────────────────┬───────────────────────┐
|
||||||
│ Afrikaans - af │ Hindi - hi │ Punjabi - pa │
|
│ Afrikaans - af │ Hindi - hi │ Punjabi - pa │
|
||||||
@ -375,9 +373,9 @@ $ trans -T
|
|||||||
└───────────────────────┴───────────────────────┴───────────────────────┘
|
└───────────────────────┴───────────────────────┴───────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
想了解更多选项的内容,可以查看 `man` 页.
|
想了解更多选项的内容,可以查看其 man 手册。
|
||||||
|
|
||||||
```shell
|
```
|
||||||
$ man trans
|
$ man trans
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -386,8 +384,8 @@ $ man trans
|
|||||||
via: https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/
|
via: https://www.2daygeek.com/translate-shell-a-tool-to-use-google-translate-from-command-line-in-linux/
|
||||||
|
|
||||||
作者:[Magesh Maruthamuthu][a]
|
作者:[Magesh Maruthamuthu][a]
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
译者:[lujun9972](https://github.com/lujun9972 )
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
校对:[wxy](https://github.com/wxy)
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user