自動建議

在 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 (under Automatic suggestions in 管理介面) or at the project settings:

../_images/project-machinery.webp

備註

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 來源語言.

也參考

自動建議

Alibaba

Added in version 5.3.

服務編號:

alibaba

組態:

key

存取金鑰 ID

secret

存取金鑰 secret

region

區域 ID

Alibaba Translate is a neural machine translation service for translating text and it supports up to 214 language pairs.

Amagama

服務編號:

amagama

組態:

This service has no configuration.

Special installation of tmserver run by the authors of Virtaal.

Apertium APy

服務編號:

apertium-apy

組態:

url

API URL

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

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

Amazon Translate

服務編號:

aws

組態:

key

存取金鑰 ID

secret

API 金鑰

region

區域名稱

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

Baidu

服務編號:

baidu

組態:

key

使用者端 ID

secret

使用者端秘密金鑰 (secret)

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

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

DeepL

服務編號:

deepl

組態:

url

API URL

key

API 金鑰

formality

正式程度

如果語言沒有特別指定是否為書面語,則使用指定的正式程度

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/ (在 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.

Weblate supports DeepL formality, it will choose matching one based on the language (for example, there is de@formal and de@informal).

The service automatically uses 詞彙表, see Glossaries in automatic suggestion.

Glosbe

服務編號:

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

Google Cloud Translation Basic

服務編號:

google-translate

組態:

key

API 金鑰

Machine translation service provided by the Google Cloud services.

This service uses the Google Translation API v2, and you need to obtain an API key and turn on billing in the Google API console.

Google Cloud Translation Advanced

服務編號:

google-translate-api-v3

組態:

credentials

Google 翻譯服務帳號資訊

輸入服務帳號的 JSON 金鑰。

project

Google 翻譯專案

輸入您 Google Cloud 專案的數字或字母 ID。

location

Google Translate 位置

選擇您用在 Google Cloud 專案,或者是位置最靠近您的 Google Cloud Translation 區域。

Machine translation service provided by the Google Cloud services.

This service uses the Google Translation API v3 and you need credentials in JSON format to access it.

In order to use this service, you first need to go through the following steps:

  1. Select or create a Cloud Platform project.

  2. Enable billing for your project.

  3. Enable the Cloud Translation.

  4. Setup Authentication.

IBM Watson Language Translator

Added in version 4.16.

服務編號:

ibm

組態:

url

API URL

key

API 金鑰

警告

This service is deprecated by vendor and will be withdrawn entirely as of 10 December 2024.

IBM Watson Language Translator translates text from one language to another. The service offers multiple domain-specific models.

LibreTranslate

Added in version 4.7.1.

服務編號:

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/ (官方公開服務)

Requires an API key to use outside of the website.

Azure AI Translator

服務編號:

microsoft-translator

組態:

key

API 金鑰

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 – 中國

api.cognitive.microsofttranslator.us – Azure US Government cloud

endpoint_url

身份核對服務 URL

可以使用下方的區域欄位指定區域性或多服務。

Available choices:

api.cognitive.microsoft.com – Global

api.cognitive.azure.cn – China

api.cognitive.microsoft.us – Azure US Government cloud

region

身份核對服務區域

category

類別

Specify a customized system category ID to use it instead of general one.

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

Weblate 實施了 Translator API V3.

The service automatically uses 詞彙表, see Glossaries in automatic suggestion.

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.

You can also specify a custom category to use custom translator.

提示

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

ModernMT

Added in version 4.2.

服務編號:

modernmt

組態:

url

API URL

key

API 金鑰

也參考

ModernMT API

MyMemory

服務編號:

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 網站

Netease Sight

服務編號:

netease-sight

組態:

key

使用者端 ID

secret

使用者端秘密金鑰 (secret)

Machine translation service provided by NetEase.

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

OpenAI

Added in version 5.3.

服務編號:

openai

組態:

key

API 金鑰

model

OpenAI 模型

Available choices:

auto – Automatic selection

gpt-4-1106-preview – GPT-4 Turbo

gpt-4 – GPT-4

gpt-3.5-turbo – GPT-3.5 Turbo

persona

翻譯者角色描述

描述翻譯者的角色描述,提高翻譯的準確性,比如:「你是名松鼠飼養員。」

style

翻譯者風格

描述翻譯風格,如:「翻譯得口語化。」

Performs translation using OpenAI.

The OpenAI API is powered by a diverse set of models with different capabilities and price points. Automatic selection chooses the best model available, but you might want to choose a specific model that matches your needs.

Use persona and style fields to further fine-tune translations. These will be used in a prompt for OpenAI and allow you to change the style of the translations.

The service automatically uses 詞彙表, see Glossaries in automatic suggestion.

SAP Translation Hub

服務編號:

sap-translation-hub

組態:

url

API URL

key

API 金鑰

username

SAP 使用者名稱

password

SAP 密碼

enable_mt

啟用機器翻譯

domain

翻譯領域

翻譯領域的 ID,例如 BC。若不指定領域,這個方法會搜尋所有可用領域中的翻譯。

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.

為了存取正式環境的 API,您需要設定 url, usernamepassword

Systran

服務編號:

systran

組態:

key

API 金鑰

Machine translation service provided by Systran.

This service uses an API, and you need to obtain API key at <https://translate.systran.net/en/account>.

tmserver

服務編號:

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. 設定 Weblate 與它建立連線,預設的 URL 為 http://localhost:8888/tmserver/

Weblate

服務編號:

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 翻譯記憶

服務編號:

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

服務編號:

yandex

組態:

key

API 金鑰

Yandex 提供的機器翻譯服務。

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

Yandex v2

Added in version 5.1.

服務編號:

yandex-v2

組態:

key

API 金鑰

Yandex 提供的機器翻譯服務。

This service uses a Translation API, and you need to obtain an API key from Yandex Cloud.

Youdao Zhiyun

服務編號:

youdao-zhiyun

組態:

key

使用者端 ID

secret

使用者端秘密金鑰 (secret)

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

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

Custom machine translation

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

# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later

"""Machine translation example."""

import dictionary  # type: ignore[import-not-found]

from weblate.machinery.base import DownloadTranslations, 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,
        threshold: int = 75,
    ) -> DownloadTranslations:
        """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.