機械翻訳¶
複数の機械翻訳サービスに対応した機能を標準搭載しています。管理者は、各サービスを MT_SERVICES
を設定して個別に有効にします。機械翻訳サービスは利用規約の対象となるため、あなたが望む方法で利用できることを確認してください。
原文の言語は、Project configuration から設定します。
amaGama¶
特別にインストールされて動作している、Virtaal の作成者自身が作成した tmserver 。
weblate.machinery.tmserver.AmagamaTranslation
を MT_SERVICES
に追加して、このサービスを有効にします。
Apertium¶
限定した言語セットに対して翻訳を提供する Libre ソフトウェアの機械翻訳プラットフォームです。
Apertium が推奨する使用方法は、Apertium-APy サーバーを独自に実行することです。
このサービスを有効にするには、MT_SERVICES
に weblate.machinery.apertium.ApertiumAPYTranslation
を追加し、MT_APERTIUM_APY
を設定します。
AWS¶
バージョン 3.1 で追加.
Amazon Translate は、対応している多くの言語間でテキストを英語に、またその逆に翻訳したりするためのニューラル機械翻訳サービスです。
1. Turn on this service by adding weblate.machinery.aws.AWSTranslation
to
MT_SERVICES
.
boto3 モジュールをインストールする。
Weblate を設定する。
Baidu API machine translation¶
バージョン 3.2 で追加.
Machine translation service provided by Baidu.
This service uses an API and you need to obtain an ID and API key from Baidu to use it.
Turn on this service by adding weblate.machinery.baidu.BaiduTranslation
to
MT_SERVICES
and set MT_BAIDU_ID
and
MT_BAIDU_SECRET
.
DeepL¶
バージョン 2.20 で追加.
DeepL is paid service providing good machine translation for a few languages. You need to purchase DeepL API subscription or you can use legacy DeepL Pro (classic) plan.
Turn on this service by adding weblate.machinery.deepl.DeepLTranslation
to
MT_SERVICES
and set MT_DEEPL_KEY
.
ヒント
In case you have subscription for CAT tools, you are supposed to use "v1
API" instead of default "v2" used by Weblate (it is not really an API
version in this case). You can toggle this by MT_DEEPL_API_VERSION
.
Glosbe¶
Free dictionary and translation memory for almost every living language.
The API is gratis to use, but subject to the used data source license. There is a limit of calls that may be done from one IP in a set period of time, to prevent abuse.
Turn on this service by adding weblate.machinery.glosbe.GlosbeTranslation
to
MT_SERVICES
.
Google Translate¶
Machine translation service provided by Google.
This service uses the Google Translation API, and you need to obtain an API key and turn on billing in the Google API console.
To turn on this service, add weblate.machinery.google.GoogleTranslation
to
MT_SERVICES
and set MT_GOOGLE_KEY
.
Google Translate API V3 (Advanced)¶
Machine translation service provided by Google Cloud services.
This service differs from the former one in how it authenticates.
To enable service, add weblate.machinery.googlev3.GoogleV3Translation
to
MT_SERVICES
and set
If location fails, you may also need to specify MT_GOOGLE_LOCATION
.
Microsoft Cognitive Services Translator¶
バージョン 2.10 で追加.
Machine translation service provided by Microsoft in Azure portal as a one of Cognitive Services.
Weblate implements Translator API V3.
To enable this service, add weblate.machinery.microsoft.MicrosoftCognitiveTranslation
to
MT_SERVICES
and set MT_MICROSOFT_COGNITIVE_KEY
.
Translator Text API V2¶
The key you use with Translator API V2 can be used with API 3.
Translator Text API V3¶
Azure ポータルに登録して、そこで取得したキーの使用が必要です。新しい Azure キーを使用する場合は、サービスの言語に対して MT_MICROSOFT_REGION
を設定することも必要です。
Microsoft Terminology Service¶
バージョン 2.19 で追加.
The Microsoft Terminology Service API を使用すると、Web サービスを使用して、言語ポータルで使用できる用語、定義、およびユーザー インターフェイス(UI)文字列にプログラムからアクセスできます。
このサービスを有効にするには、weblate.machinery.microsoftterminology.MicrosoftTerminologyService
を MT_SERVICES
に追加します。
ModernMT¶
バージョン 4.2 で追加.
Turn this service on by adding weblate.machinery.modernmt.ModernMTTranslation
to
MT_SERVICES
and configure MT_MODERNMT_KEY
.
MyMemory¶
Huge translation memory with machine translation.
Free, anonymous usage is currently limited to 100 requests/day, or to 1000
requests/day when you provide a contact e-mail address in MT_MYMEMORY_EMAIL
.
You can also ask them for more.
Turn on this service by adding weblate.machinery.mymemory.MyMemoryTranslation
to
MT_SERVICES
and set MT_MYMEMORY_EMAIL
.
NetEase Sight API machine translation¶
バージョン 3.3 で追加.
Machine translation service provided by Netease.
This service uses an API, and you need to obtain key and secret from NetEase.
Turn on this service by adding weblate.machinery.youdao.NeteaseSightTranslation
to
MT_SERVICES
and set MT_NETEASE_KEY
and
MT_NETEASE_SECRET
.
tmserver¶
You can run your own translation memory server by using the one bundled with Translate-toolkit and let Weblate talk to it. You can also use it with an amaGama server, which is an enhanced version of tmserver.
First you will want to import some data to the translation memory:
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
Start tmserver to listen to your requests:
tmserver -d /var/lib/tm/db
Configure Weblate to talk to it:
MT_TMSERVER = "http://localhost:8888/tmserver/"
Yandex Translate¶
Machine translation service provided by Yandex.
This service uses a Translation API, and you need to obtain an API key from Yandex.
Turn on this service by adding weblate.machinery.yandex.YandexTranslation
to
MT_SERVICES
, and set MT_YANDEX_KEY
.
Youdao Zhiyun API machine translation¶
バージョン 3.2 で追加.
Machine translation service provided by Youdao.
This service uses an API, and you need to obtain an ID and an API key from Youdao.
Turn on this service by adding weblate.machinery.youdao.YoudaoTranslation
to
MT_SERVICES
and set MT_YOUDAO_ID
and
MT_YOUDAO_SECRET
.
Weblate¶
Weblate can be the source of machine translations as well. It is based on the Woosh fulltext engine, and provides both exact and inexact matches.
Turn on these services by adding weblate.machinery.weblatetm.WeblateTranslation
to
MT_SERVICES
.
Weblate Translation Memory¶
バージョン 2.20 で追加.
The 翻訳メモリ can be used as a source for machine translation suggestions as well.
Turn on these services by adding weblate.memory.machine.WeblateMemory
to
the MT_SERVICES
. This service is turned on by
default.
SAP Translation Hub¶
Machine translation service provided by SAP.
You need to have a SAP account (and enabled the SAP Translation Hub in the SAP Cloud Platform) to use this service.
Turn on this service by adding weblate.machinery.saptranslationhub.SAPTranslationHub
to
MT_SERVICES
and set the appropriate access to either
sandbox or the productive API.
注釈
To access the Sandbox API, you need to set MT_SAP_BASE_URL
and MT_SAP_SANDBOX_APIKEY
.
To access the productive API, you need to set MT_SAP_BASE_URL
,
MT_SAP_USERNAME
and MT_SAP_PASSWORD
.
Custom machine translation¶
You can also implement your own machine translation services using a few lines of
Python code. This example implements machine translation in a fixed list of
languages using dictionary
Python module:
#
# Copyright © 2012 - 2021 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 own class in MT_SERVICES
and Weblate
will start using that.