アドオン¶
バージョン 2.19 で追加.
Addons provide ways to customize translation workflow. They can be installed in the translation component view, and work behind the scenes. Addon management is available from the Manage ↓ Addons menu of each respective translation component for admins.
内蔵アドオン¶
自動翻訳¶
バージョン 3.9 で追加.
自動翻訳または他のコンポーネントを使用して文字列を自動的に翻訳します。
This addon is triggered automatically when new strings appear in a component.
JavaScript 現地語化 CDN¶
バージョン 4.2 で追加.
JavaScript または HTML の現地語化用に CDN を追加します。
It can be used to localize static HTML pages or used to load localization in the JavaScript code.
Upon installation the addon generates unique URL for your component which you can include in the HTML documents to get them localized. See Translating HTML and JavaScript using Weblate CDN for more details.
翻訳ファイルのクリーンアップ¶
単一言語の基本ファイルに合わせてすべての翻訳ファイルを更新します。ほとんどのファイル形式で、基本ファイルに存在しない、無効な翻訳キーを削除します。
言語の一貫性¶
1 つのプロジェクト内のすべてのコンポーネントに、追加されたすべての言語の翻訳を適用します。
It creates empty translations in languages that have unadded components.
Missing languages are checked once every 24 hours and when a new language is added in Weblate.
Unlike most others, this addon affects the whole project.
ヒント
Auto-translate the newly added strings with 自動翻訳.
コンポーネントの検出¶
バージョン管理システムのファイル変更に基づいて、プロジェクトコンポーネントを自動的に追加または削除します。
It is triggered on every VCS update, and otherwise similar to the import_project
management command. This way you can track multiple translation
components within one VCS.
Create one main component least likely to disappear in the future, and others will employ Weblate の内部 URL to it as a VCS configuration, and configure it to find all components in it.
The matching is done using regular expressions, where power is a tradeoff for complexity in configuration. Some examples for common use cases can be found in the addon help section.
Once you hit Save, a preview of matching components will be presented, from where you can check whether the configuration actually matches your needs:
一括編集¶
バージョン 3.11 で追加.
文字列のフラグ、ラベル、状態を一括編集します。
Automating the labeling of new strings can be useful (start out with search query NOT
has:label
and add desired labels till all strings are properly labeled).
You can also carry out any other automated operations for Weblate metadata.
参考
未翻訳の翻訳文に "要編集" フラグを付ける¶
バージョン 3.1 で追加.
VCS からインポートされた新しい翻訳可能な文字列が原文と一致するたびに、Weblate は "要編集" フラグを付けます。これは、文字列が翻訳されていない場合であっても、すべての文字列を含むファイル形式には特に便利です。
新しい原文に "要編集" フラグを付ける¶
新しい原文を VCS からインポートすると、Weblate は毎回 "要編集" フラグを付けます。このため、開発者が作成した原文を簡単にフィルタしたり、編集したりできます。
新しい翻訳に "要編集" フラグを付ける¶
新しい翻訳可能な文章を VCS からインポートすると、Weblate は毎回 "要編集" フラグを付けます。これにより、開発者が作成した翻訳文を簡単にフィルタしたり、編集したりできます。
統計データの生成¶
翻訳の詳細情報ファイルを生成します。
You can use Django template in both filename and content, see Template markup for a detailed markup description.
For example generating summary file for each translation:
- 生成ファイルの名前
locale/{{ language_code }}.json
- Content
{ "language": "{{ language_code }}", "strings": "{{ stats.all }}", "translated": "{{ stats.translated }}", "last_changed": "{{ stats.last_changed }}", "last_author": "{{ stats.last_author }}", }
コメント内の貢献者情報¶
PO ファイルヘッダのコメントを更新し、貢献者名と貢献年を追加します。
The PO file header will contain a list of contributors and years contributed:
# Michal Čihař <michal@cihar.com>, 2012, 2018, 2019, 2020.
# Pavel Borecki <pavel@example.com>, 2018, 2019.
# Filip Hron <filip@example.com>, 2018, 2019.
# anonymous <noreply@weblate.org>, 2019.
configure ファイルの ALL_LINGUAS 変数の更新¶
Updates the ALL_LINGUAS variable in configure
, configure.in
or any
configure.ac
files, when a new translation is added.
gettext 出力のカスタマイズ¶
改行処理など、 gettext の出力動作をカスタマイズできます。
It offers the following options:
Wrap lines at 77 characters and at newlines
改行文字でのみ改行する
改行しない
注釈
By default gettext wraps lines at 77 characters and for newlines.
With the --no-wrap
parameter, it wraps only at newlines.
LINGUAS ファイルの更新¶
新しい翻訳が追加されたときに LINGUAS ファイルを更新します。
MO ファイルの生成¶
変更された PO ファイルごとに自動的に MO ファイルを生成します。
POT に一致する PO ファイルの更新 (msgmerge)¶
Updates all PO files to match the POT file using msgmerge. Triggered whenever new changes are pulled from the upstream repository and updates all translation files to match 新しい翻訳のテンプレート. You can configure most of the msgmerge command line options through the addon configuration.
Git コミットをスカッシュ¶
変更をプッシュする前に、Git コミットをスカッシュします。
You can choose one of following modes:
バージョン 3.4 で追加.
すべてのコミットを 1 つにする
言語別に
ファイル別に
バージョン 3.5 で追加.
翻訳者別に
元のコミット メッセージは保持されますが、 Per author を選択するか、コミット メッセージに含めるようカスタマイズしない限り、翻訳者情報は失われます。
バージョン 4.1 で追加.
The original commit messages can optionally be overridden with a custom commit message.
Trailers (commit lines like Co-authored-by: ...
) can optionally be removed
from the original commit messages and appended to the end of the squashed
commit message. This also generates proper Co-authored-by:
credit for every
translator.
JSON 出力形式のカスタマイズ¶
インデント処理や並べ替えなど、JSON 出力形式を調整できます。
Java プロパティ ファイルの整形¶
Java プロパティ ファイルをソートします。
古いコメントの削除¶
バージョン 3.7 で追加.
コメントを削除するまでの期間を設定します。
This can be useful to remove old comments which might have become outdated. Use with care as comment being old does not mean they have lost their importance.
古い提案の削除¶
バージョン 3.7 で追加.
提案を削除するまでの期間を設定します。
This can be very useful in connection with suggestion voting (see 相互評価) to remove suggestions which don't receive enough positive votes in a given timeframe.
RESX ファイルの更新¶
バージョン 3.9 で追加.
アップストリームの単一言語の基本ファイルに合わせて、すべての翻訳ファイルを更新します。使われていない文字列は削除し、新しい文字列は原文のコピーとして追加します。
ヒント
Use 翻訳ファイルのクリーンアップ if you only want to remove stale translation keys.
Customizing list of addons¶
The list of addons is configured by WEBLATE_ADDONS
.
To add another addon, simply include class absolute name in this setting.
Writing addon¶
You can write your own addons too, all you need to do is subclass BaseAddon
,
define the addon metadata and implement a callback which will do the processing.
Here is an example addon:
#
# 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/>.
#
from django.utils.translation import gettext_lazy as _
from weblate.addons.base import BaseAddon
from weblate.addons.events import EVENT_PRE_COMMIT
class ExampleAddon(BaseAddon):
# Filter for compatible components, every key is
# matched against property of component
compat = {"file_format": {"po", "po-mono"}}
# List of events addon should receive
events = (EVENT_PRE_COMMIT,)
# Addon unique identifier
name = "weblate.example.example"
# Verbose name shown in the user interface
verbose = _("Example addon")
# Detailed addon description
description = _("This addon does nothing it is just an example.")
# Callback to implement custom behavior
def pre_commit(self, translation, author):
return
Executing scripts from addon¶
Addons can also be used to execute external scripts. This used to be integrated in Weblate, but now you have to write some code to wrap your script with an addon.
#
# 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/>.
#
"""Example pre commit script."""
from django.utils.translation import gettext_lazy as _
from weblate.addons.events import EVENT_PRE_COMMIT
from weblate.addons.scripts import BaseScriptAddon
class ExamplePreAddon(BaseScriptAddon):
# Event used to trigger the script
events = (EVENT_PRE_COMMIT,)
# Name of the addon, has to be unique
name = "weblate.example.pre"
# Verbose name and long descrption
verbose = _("Execute script before commit")
description = _("This addon executes a script.")
# Script to execute
script = "/bin/true"
# File to add in commit (for pre commit event)
# does not have to be set
add_file = "po/{{ language_code }}.po"
For installation instructions see 品質検査、アドオン、自動修正のカスタマイズ.
The script is executed with the current directory set to the root of the VCS repository for any given component.
Additionally, the following environment variables are available:
-
WL_VCS
¶ Version control system used.
-
WL_REPO
¶ Upstream repository URL.
-
WL_PATH
¶ Absolute path to VCS repository.
-
WL_BRANCH
¶ バージョン 2.11 で追加.
Repository branch configured in the current component.
-
WL_FILEMASK
¶ Filemask for current component.
-
WL_TEMPLATE
¶ Filename of template for monolingual translations (can be empty).
-
WL_NEW_BASE
¶ バージョン 2.14 で追加.
Filename of the file used for creating new translations (can be empty).
-
WL_FILE_FORMAT
¶ Fileformat used in current component.
-
WL_LANGUAGE
¶ Language of currently processed translation (not available for component level hooks).
-
WL_PREVIOUS_HEAD
¶ Previous HEAD on update (available only when running post update hook).
-
WL_COMPONENT_SLUG
¶ バージョン 3.9 で追加.
Component slug used to construct URL.
-
WL_PROJECT_SLUG
¶ バージョン 3.9 で追加.
Project slug used to construct URL.
-
WL_COMPONENT_NAME
¶ バージョン 3.9 で追加.
Component name.
-
WL_PROJECT_NAME
¶ バージョン 3.9 で追加.
Project name.
-
WL_COMPONENT_URL
¶ バージョン 3.9 で追加.
Component URL.
-
WL_ENGAGE_URL
¶ バージョン 3.9 で追加.
Project engage URL.
Post update repository processing¶
Post update repository processing can be used to update translation files when the VCS upstream source changes. To achieve this, please remember that Weblate only sees files committed to the VCS, so you need to commit changes as a part of the script.
For example with Gulp you can do it using following code:
#! /bin/sh
gulp --gulpfile gulp-i18n-extract.js
git commit -m 'Update source strings' src/languages/en.lang.json
Pre commit processing of translations¶
Use the commit script to automatically make changes to the translation before it is committed to the repository.
It is passed as a single parameter consisting of the filename of a current translation.