Configuring automatic suggestions

在 4.13 版本變更: Prior to Weblate 4.13, the services were configured in the 配置.

The support for several machine translation and translation memory services is built-in. Each service can be turned on by the administrator for whole site or at the project settings:

../_images/project-machinery.png

備註

They come subject to their terms of use, so ensure you are allowed to use them how you want.

The services translate from the source language as configured at 組件配置, see 來源語言.

也參考

自動建議

Amagama

Service ID

amagama

配置

This service has no configuration.

Special installation of tmserver run by the authors of Virtaal.

Apertium APy

Service ID

apertium-apy

配置

url

API URL

開源原件機器翻譯平台提供一組有限語言的翻譯。

使用 Apertium的推薦方式是運行您自己的 Apertium-APy 服務器。

AWS

在 3.1 版本新加入.

Service ID

aws

配置

key

存取金鑰 ID

secret

API 祕密金鑰

region

區域名稱

Amazon Translate 是神經機器翻譯服務,用於將英語與廣泛支持的語言進行互譯。

Baidu

在 3.2 版本新加入.

Service ID

baidu

配置

key

用戶端 ID

secret

用戶端秘密金鑰 (secret)

由百度提供的機器翻譯服務。

這項服務使用 API,並且您需要從百度獲得 ID 和 API 密鑰來使用它。

DeepL

在 2.20 版本新加入.

Service ID

deepl

配置

url

API URL

key

API 金鑰

DeepL 是付費服務,提供一些語言的良好機器翻譯。您需要購買 DeepL API 訂閱,或者您可以使用傳統的 DeepL Pro (classic) 計劃。

API URL to use with the DeepL service. At the time of writing, there is the v1 API as well as a free and a paid version of the v2 API.

https://api.deepl.com/v2/ (default in Weblate)

Is meant for API usage on the paid plan, and the subscription is usage-based.

https://api-free.deepl.com/v2/

Is meant for API usage on the free plan, and the subscription is usage-based.

https://api.deepl.com/v1/

Is meant for CAT tools and is usable with a per-user subscription.

此前 Weblate 被 DeepL 分類為計算機輔助翻譯工具,因此應該使用 v1 API,但現在應該使用 v2 API。這樣默認為 v2,在你有現有的計算機輔助翻譯工具訂閱,並想要 Weblate 使用它的情況下,可以將其更改為 v1。

The easiest way to find out which one to use is to open an URL like the following in your browser:

https://api.deepl.com/v2/translate?text=Hello&target_lang=FR&auth_key=XXX

Replace the XXX with your auth_key. If you receive a JSON object which contains 「Bonjour」, you have the correct URL; if not, try the other three.

Glosbe

Service ID

glosbe

配置

This service has no configuration.

幾乎每一種活語言的免費字典與翻譯服務。

The API is gratis to use, but usage of the translations is subject to the license of the used data source. There is a limit of calls that may be done from one IP in a set period of time, to prevent abuse.

也參考

Glosbe website

谷歌翻譯

Service ID

google-translate

配置

key

API 金鑰

Google 提供的機器翻譯服務。

這項服務使用了 Google Translation API,您需要得到 API 密鑰,並在 Google API 控制台打開記費。

Google Translate API v3

Service ID

google-translate-api-v3

配置

credentials

Google 翻譯服務帳號資訊

project

Google 翻譯專案

location

Google Translate 位置

Google 雲服務提供的機器翻譯服務。

LibreTranslate

在 4.7.1 版本新加入.

Service ID

libretranslate

配置

url

API URL

key

API 金鑰

LibreTranslate is a free and open-source service for machine translations. The public instance requires an API key, but LibreTranslate can be self-hosted and there are several mirrors available to use the API for free.

https://libretranslate.com/ (official public instance)

Requires an API key to use outside of the website.

Microsoft Terminology

在 2.19 版本新加入.

Service ID

microsoft-terminology

配置

This service has no configuration.

Microsoft Terminology Service API 允許您通過 Web 服務,可編程地訪問 Langurage Portal 上可用的術語、定義和用戶界面( UI )字符串。

微軟的 Translator

在 2.10 版本新加入.

Service ID

microsoft-translator

配置

key

API 金鑰

endpoint_url

應用程式端點 URL

base_url

應用程式基礎 URL

Available choices:

api.cognitive.microsofttranslator.com – Global (non-regional)

api-apc.cognitive.microsofttranslator.com – Asia Pacific

api-eur.cognitive.microsofttranslator.com – Europe

api-nam.cognitive.microsofttranslator.com – North America

api.translator.azure.cn – China

region

應用程式區域

由 Microsoft 在 Azure 門戶提供的機器翻譯服務,作為 Cognitive Services 的一種。

Weblate 實施了 Translator API V3.

Translator Text API 第二版

您用於Translator API V2 的密鑰可以用於 API 3。

Translator Text API 第三版

You need to register at Azure portal and use the key you obtain there. With new Azure keys, you also need to set region to locale of your service.

提示

對於 Azure 中國,請使用你的 Azure Portal 的端點。

ModernMT

在 4.2 版本新加入.

Service ID

modernmt

配置

url

API URL

key

API 金鑰

也參考

ModernMT API,

MyMemory

Service ID

mymemory

配置

email

聯絡信箱

username

使用者名稱

key

API 金鑰

使用機器翻譯的巨量翻譯記憶庫。

Free, anonymous usage is currently limited to 100 requests/day, or to 1000 requests/day when you provide a contact e-mail address in email. You can also ask them for more.

也參考

MyMemory website

Netease Sight

在 3.3 版本新加入.

Service ID

netease-sight

配置

key

用戶端 ID

secret

用戶端秘密金鑰 (secret)

Machine translation service provided by NetEase.

這項服務使用 API,兵器額您需要從網易得到密鑰和密碼。

SAP Translation Hub

Service ID

sap-translation-hub

配置

url

API URL

key

API 金鑰

username

SAP 使用者名稱

password

SAP 密碼

enable_mt

啟用機器翻譯

SAP 提供的機器翻一下服務。

You need to have a SAP account (and the SAP Translation Hub enabled in the SAP Cloud Platform) to use this service.

You can also configure whether to also use machine translation services, in addition to the term database.

備註

To access the Sandbox API, you need to set url and key.

To access the productive API, you need to set url, username and password.

tmserver

Service ID

tmserver

配置

url

API URL

您可以通過使用 Translate-toolkit綁定的一個服務器並與之對話,來運行您自己的翻譯服務器。您還可以將它與 amaGama 服務器一起使用,它是 tmserver 的增強版本。

  1. 首先您會想要將一些數據導入翻譯記憶庫:

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. Configure Weblate to talk to it, the default URL is http://localhost:8888/tmserver/.

Weblate

Service ID

weblate

配置

This service has no configuration.

Weblate machine translation service can provide translations for strings that are already translated inside Weblate. It looks for exact matches in the existing strings.

Weblate Translation Memory

在 2.20 版本新加入.

Service ID

weblate-translation-memory

配置

This service has no configuration.

Use 翻譯記憶 as a machine translation service. Any string that has been translated in past (or uploaded to the translation memory) can be translated in this way.

Yandex

Service ID

yandex

配置

key

API 金鑰

Yandex 提供的機器翻譯服務。

這項服務使用翻譯 API,您需要從 Yandex 得到 API 密鑰。

Youdao Zhiyun

在 3.2 版本新加入.

Service ID

youdao-zhiyun

配置

key

用戶端 ID

secret

用戶端秘密金鑰 (secret)

有道提供的機器翻譯服務。

這項服務使用 API,您需要從有道獲得 ID 和 API 密鑰。

Custom machine translation

您還可以通過使用一些 Python 代碼來實施您自己的機器翻譯服務。這個例子使用 dictionary Python 模塊來實施一組固定語言的機器翻譯:

#
# Copyright © 2012–2022 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: str,
        unit,
        user,
        search: bool,
        threshold: int = 75,
    ):
        """Return tuple with translations."""
        for t in dictionary.translate(text):
            yield {"text": t, "quality": 100, "service": self.name, "source": text}

You can list your own class in WEBLATE_MACHINERY and Weblate will start using that.