网站搜索

适用于 Linux 的最佳命令行语言翻译器


语言翻译应用程序的重要性怎么强调都不为过,特别是对于那些经常旅行或与不定期使用相同语言的人交流的人来说。

今天,我向您介绍 Linux 上最好的基于命令行的翻译工具。

1.DeepL翻译器CLI

DeepL Translator Cli 是一款免费开源的命令行语言翻译器,它使用先进的机器学习技术,使用户能够在语言之间翻译文本并检测输入文本的语言。它由德国科技公司 DeepL 提供支持,并根据 MIT 许可发布。

它支持的语言包括英语(EN)、德语(DE)、法语(FR)、意大利语(IT)、荷兰语(NL)、西班牙语(ES)、俄语、葡萄牙语和波兰语(PL),而终端工具是免费,DeepL 为感兴趣的用户提供订阅计划。

在 Linux 中安装 DeepL Translator CLI

要安装 DeepL Translator 命令行工具,首先需要在 Linux 发行版中安装最新版本的 Node.js。

接下来,使用以下命令在 DebianUbuntu 发行版上使用 Debian 软件包存储库安装 Yarn 软件包依赖管理器。

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn

CentOSFedoraRHEL 发行版上,您可以通过 RPM 软件包存储库安装 Yarn

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum install yarn  [On CentOS/RHEL]
dnf install yarn  [On Fedora]

现在使用以下命令安装DeepL Translator命令行工具。

yarn global add deepl-translator-cli

通过检查DeepL版本来验证安装状态。

deepl --version

DeepL 的工作原理是对 deepl.com 主网站进行 API 调用,因此目前您需要在线才能使用它。据报道,它运行在一台速度为 5.1 petaFLOPS 的超级计算机上,速度足以瞬间检测和翻译语言。

DeepL 用法示例

Translate text into German
deepl translate -t 'DE' 'How do you do?'

# Pipe text from standard input
echo 'How do you do?' | deepl translate -t 'DE'

# Detect language
deepl detect 'Wie geht es Ihnen?'

# For help
deepl -h
deepl translate -h
deepl detect -h

2. 翻译Shell

Translate Shell(以前称为Google Translate CLI)是一款免费开源命令行语言翻译工具,由 Google Translate、Yandex Translate、Apertium 提供支持和必应翻译。它适用于大多数 POSIX 兼容系统,包括 Windows(通过 Cygwin、WSL 或 MSYS2)、GNU/Linux、macOS 和 BSD。

Translate Shell 允许用户使用它进行简单翻译或作为交互式 shell。对于简单翻译,Translate Shell 默认情况下会提供翻译文本的详细信息,除非使用关键字 Brief 排除详细信息。

trans 'Saluton, Mondo!'
Saluton, Mondo!

Hello, World!

Translations of Saluton, Mondo!
[ Esperanto -> English ]
Saluton ,
    Hello,
Mondo !
    World!
trans -brief 'Saluton, Mondo!'
Hello, World!

当用作交互式 shell 时,它将在您逐行输入文本时进行翻译。例如,

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.
> 幸福になるためには、人から愛されるのが一番の近道。
In order to be happy, the best way is to be loved by people.

在 Linux 中安装 Translate Shell

我推荐的下载方法是从这里获取独立的可执行文件,将其放在您的路径中,然后运行以下命令:

wget git.io/trans
chmod +x ./trans

有关安装和使用的更多详细信息,请查看此处的官方 GitHub 页面。

您还知道其他很棒的 Linux 命令行文本翻译应用程序吗?在下面的评论部分添加您的建议。