机器翻译

内建了几种及其翻译服务的支持,并且每一个可以由管理员使用 MT_SERVICES 来打开。它们受到自己的使用条款约束,因此请确认允许您以所需要的方式来使用它。

源语言可以在 项目配置 配置。

amaGama

由 Virtaal 作者运行的 tmserver 的特殊安装。

通过将 weblate.machinery.tmserver.AmagamaTranslation 添加到 MT_SERVICES 来打开这个服务。

Apertium

开源原件机器翻译平台提供一组有限语言的翻译。

使用 Apertium的推荐方式是运行您自己的 Apertium-APy 服务器 。

通过将``weblate.machinery.apertium.ApertiumAPYTranslation`` 添加到 MT_SERVICES 中,并设置 MT_APERTIUM_APY 来打开这项服务。

AWS

3.1 新版功能.

Amazon Translate 是神经机器翻译服务,用于将英语与广泛支持的语言进行互译。

1. Turn on this service by adding weblate.machinery.aws.AWSTranslation to MT_SERVICES.

  1. 安装 boto3 模块。

  2. 配置 Weblate 。

Baidu API 机器翻译

3.2 新版功能.

由百度提供的机器翻译服务。

这项服务使用 API ,并且您需要从百度获得 ID 和 API 密钥来使用它。

通过将 weblate.machinery.baidu.BaiduTranslation 添加到 MT_SERVICES 并设置 MT_BAIDU_IDMT_BAIDU_SECRET 来打开这项服务。

DeepL

2.20 新版功能.

DeepL 是付费服务,提供一些语言的良好机器翻译。您需要购买 DeepL API 订阅,或者您可以使用传统的 DeepL Pro (classic) 计划。

通过将 weblate.machinery.deepl.DeepLTranslation 添加到 MT_SERVICES ,并设置 MT_DEEPL_KEY 来打开这项服务。

提示

在您已经订阅 CAT 工具的情况下,您可能会使用 Weblate 使用的 “v1 API” instead of default “v2” (在这种情况下不是真正的 API 版本)。您可以通过 MT_DEEPL_API_VERSION 来切换。

Glosbe

几乎每一种活语言的免费字典与翻译服务。

API 免费使用,但受到使用数据源许可的约束。一段时期有少量来自一个 IP 的呼叫,防止侵权。

通过将 weblate.machinery.glosbe.GlosbeTranslation 添加到 MT_SERVICES 来打开这项服务。

Google Translate

Google 提供的机器翻译服务。

这项服务使用了 Google Translation API ,您需要得到 API 密钥,并在 Google API 控制台打开记费。

weblate.machinery.google.GoogleTranslation 添加到 MT_SERVICES ,并设置 MT_GOOGLE_KEY 来打开这项服务。

Google Translate API V3 (高级版)

Google 云服务提供的机器翻译服务。

这项服务在如何进行身份验证方面不同于前面的服务。将 weblate.machinery.googlev3.GoogleV3Translation 添加到 MT_SERVICES ,并通过后面的设置来允许服务

如果 location 失败,您还需要指定 MT_GOOGLE_LOCATION

Microsoft Cognitive Services Translator

2.10 新版功能.

由 Microsoft 在 Azure 门户提供的机器翻译服务,作为 Cognitive Services 的一种。

Weblate 实施了 Translator API V3.

为了允许这项服务,将 weblate.machinery.microsoft.MicrosoftCognitiveTranslation 添加到 MT_SERVICES ,并设置 MT_MICROSOFT_COGNITIVE_KEY

Translator Text API V2

您用于Translator API V2 的密钥可以用于 API 3 。

Translator Text API V3

您需要在 Azure 门户注册,并使用得到的密钥。关于新的 Azure 密钥,您还需要设置 MT_MICROSOFT_REGION 为您的服务设置地区。

Microsoft Terminology Service

2.19 新版功能.

Microsoft Terminology Service API 允许您通过 Web 服务,可编程地访问 Langurage Portal 上可用的术语、定义和用户界面( UI )字符串。

通过将 weblate.machinery.microsoftterminology.MicrosoftTerminologyService 添加到 MT_SERVICES 来打开这项服务。

ModernMT

4.2 新版功能.

通过将 weblate.machinery.modernmt.ModernMTTranslation 添加到 MT_SERVICES ,并配置 MT_MODERNMT_KEY 来打开这项服务。

MyMemory

使用机器翻译的巨量翻译记忆库。

自由匿名使用,当前限制为 100 个请求/天,或者在 MT_MYMEMORY_EMAIL 中提供电子邮箱联系地址时限制为 1000 个请求/天。您还可以向他们请求更多。

通过将 weblate.machinery.mymemory.MyMemoryTranslation 添加到 MT_SERVICES ,并设置 MT_MYMEMORY_EMAIL 来打开这项服务。

网易见外 API 机器翻译

3.3 新版功能.

网易提供的机器翻译服务。

这项服务使用 API ,兵器额您需要从网易得到密钥和密码。

通过将 weblate.machinery.youdao.NeteaseSightTranslation 添加到 MT_SERVICES 并设置 MT_NETEASE_KEYMT_NETEASE_SECRET 来打开这项服务。

tmserver

您可以通过使用 Translate-toolkit绑定的一个服务器并与之对话,来运行您自己的翻译服务器。您还可以将它与 amaGama 服务器一起使用,它是 tmserver 的增强版本。

  1. 首先您会想要将一些数据导入翻译记忆库:

2. Turn on this service by adding weblate.machinery.tmserver.TMServerTranslation to MT_SERVICES.

build_tmdb -d /var/lib/tm/db -s en -t cs locale/cs/LC_MESSAGES/django.po
build_tmdb -d /var/lib/tm/db -s en -t de locale/de/LC_MESSAGES/django.po
build_tmdb -d /var/lib/tm/db -s en -t fr locale/fr/LC_MESSAGES/django.po
  1. 启动 tmserver 来收听您的请求:

tmserver -d /var/lib/tm/db
  1. 配置 Weblate 来与之对话:

MT_TMSERVER = 'http://localhost:8888/tmserver/'

Yandex Translate

Yandex 提供的机器翻译服务。

这项服务使用翻译 API ,您需要从 Yandex 得到 API 密钥。

通过将 weblate.machinery.yandex.YandexTranslation 添加到 MT_SERVICES ,并设置 MT_YANDEX_KEY 来打开这项服务。

有道智云 API 机器翻译

3.2 新版功能.

有道提供的机器翻译服务。

这项服务使用 API ,您需要从有道获得 ID 和 API 密钥。

通过将 weblate.machinery.youdao.YoudaoTranslation 添加到 MT_SERVICES ,并设置 MT_YOUDAO_IDMT_YOUDAO_SECRET 来打开这项服务。

Weblate

Weblate 也可以作为机器翻译的来源。它基于 Woosh 全文引擎,并提供精确和和不精确的匹配。

通过将 weblate.machinery.weblatetm.WeblateTranslation 添加到 MT_SERVICES 来打开这项服务。

Weblate 翻译记忆库

2.20 新版功能.

翻译记忆库 也可以用作机器翻译建议的来源。

通过将 weblate.memory.machine.WeblateMemory 添加到 MT_SERVICES ,来打开这项服务。这项服务默认打开。

SAP Translation Hub

SAP 提供的机器翻一下服务。

您需要具有 SAP 账户(并在 SAP Cloud Platform 上允许 SAP Translation Hub )来使用这项服务。

通过将 weblate.machinery.saptranslationhub.SAPTranslationHub 添加到 MT_SERVICES ,并设置对沙箱或生产 API 的适当访问,来打开这项服务。

注解

为了访问 Sandbox API ,您需要设置 MT_SAP_BASE_URLMT_SAP_SANDBOX_APIKEY

为了访问生产 API ,您需要设置 MT_SAP_BASE_URLMT_SAP_USERNAMEMT_SAP_PASSWORD

定制化的机器翻译

您还可以通过使用一些 Python 代码来实施您自己的机器翻译服务。这个例子使用 dictionary Python 模块来实施一组固定语言的机器翻译:

#
# Copyright © 2012 - 2020 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
"""Machine translation example."""

import dictionary

from weblate.machinery.base import MachineTranslation


class SampleTranslation(MachineTranslation):
    """Sample machine translation interface."""

    name = "Sample"

    def download_languages(self):
        """Return list of languages your machine translation supports."""
        return {"cs"}

    def download_translations(self, source, language, text, unit, user, search):
        """Return tuple with translations."""
        for t in dictionary.translate(text):
            yield {"text": t, "quality": 100, "service": self.name, "source": text}

您可以在 MT_SERVICES 中列出自己的类,Weblate 就会开始使用它了。