附加组件¶
附加组件提供了自定义和自动化翻译工作流程的方法。管理员可以从每个相应翻译项目或部件的 操作 ↓ 附加组件 菜单添加和管理附加组件。也可以在 管理界面 中进行全站作用域的附加组件安装。
提示
您也可以使用 API、DEFAULT_ADDONS 或 install_addon 来配置附加组件。
可从附加组件管理或用 API 运行默认启用手动触发的附加组件。结果记录于附加组件活动日志中。
Add-ons that expose a component API show its base URL on the add-on's API tab, alongside a link to the API root.
Add-ons are persistent administrative configuration. They run with their service identity in the scope where they are installed, rather than repeatedly using the permissions of the administrator who configured them. This ensures that equally authorized administrators see and save the same configuration, and that saving an unrelated change does not silently alter the add-on's input scope. Removing or disabling the configuring administrator does not disable the add-on.
Project and category add-ons therefore include compatible restricted components in that scope. A component add-on can use inputs outside its destination component when documented by that add-on. Automatic translation determines its source components as follows:
直接自动翻译操作使用采取操作的用户的部件权限。
A saved automatic-translation add-on uses its persistent administrative scope. Compatible components in the target project are eligible, including restricted components.
Components in another project are eligible when that project contributes to shared translation memory. This includes restricted components even though they do not create shared translation-memory entries; the add-on reads the explicitly selected component as an administrative input instead.
Restricted components remain filtered from ordinary listings and direct access. Grant add-on management permissions only to users trusted with the add-on's complete input and effect scope. See 团队作用域 and 受限制的访问.
触发附加组件的事件¶
附加组件安装¶
当附加组件被安装时触发。
部件更新¶
每当下列部件中发生更改时被触发:
仓库中字符串被改变。
添加了字符串。
添加了新翻译。
每天¶
每日触发,但附加组件通常根据 BACKGROUND_TASKS 设置在部件间分割每天的载荷。
事件变化¶
更改事件创建后触发。
手动触发¶
当从附加组件管理或 API 手动运行附加组件时触发。
添加并提交新翻译¶
新翻译被添加和提交后即刻触发。
提交更改后¶
提交更改后即刻触发。
推送仓库到上游后¶
仓库被推送到上游后即刻触发。
仓库删除后¶
删除翻译后立即触发。
拉取新更改¶
每当新更改从上游被拉取后触发。
提交更改前¶
提交更改前触发。
推送仓库到上游前¶
在仓库被推送到上游之前。
尝试更新仓库¶
尝试更新仓库前触发。
保存字符串¶
字符串被保存后即刻触发。
Unit post-sync¶
字符串与 VCS 同步后触发。
保存新创建字符串¶
新建字符串被保存后即刻触发。
内置附加组件¶
所有质量评估¶
利用大语言模型评估现有译文并记录质量检查。
This add-on evaluates existing translations using an LLM service configured under 自动建议. It does not generate suggestions or change translations. Choose an Evaluation service from the configured LLM services; credentials and project overrides are reused.
The Query selects strings using the normal search syntax. By default, translated strings are selected. Source strings, read-only strings, and glossary entries are excluded. Each request includes all translation plural forms, source text, language information, string context, glossary terms, placeholders, and configured translation instructions. This data is sent to the selected provider.
Requests group strings from the same translation in file order, using the service's automatic translation batch size (currently 20 strings for built-in LLM services). All plural forms of a string stay together. Related strings share context, allowing the evaluator to check meaning and terminology across the batch. Batching reduces the number of provider requests for scheduled, manual, and change-triggered runs; it does not skip unchanged strings.
Evaluation frequency defaults to weekly. Daily and monthly schedules are also available; disabled turns off scheduled evaluation. Background processing must be enabled. A successful full run starts the next interval. Manual runs bypass the interval. Enable Evaluate translation changes or Evaluate repository updates to additionally evaluate after those events. Installation does not immediately contact the provider. Each run can incur provider costs, including reevaluation of unchanged translations.
Evaluation runs in background tasks, with results and failure counts recorded in the existing add-on activity log. Failed requests retain existing valid findings and are tried again only by a subsequent run. Evaluation shares the service's automatic translation cooldown: rate-limit responses activate it, and batches are skipped while it is active. More specific installations take precedence: component, nearest category, project, then site-wide.
Findings appear as standard checks for accuracy, fluency, terminology, style, and
formatting. Each finding includes a minor, major, or critical severity and an
explanation. Multiple findings in one category share a check, so ignoring that
check ignores the whole category for the string. Existing search filters and API
search work, for example check:ai_accuracy. Translation flags such as
ignore-ai-accuracy disable a category; ignore-all-checks disables all checks.
Changing the source or translation removes outdated findings. Results received after any source or translation in their batch changes are discarded for the whole batch. A failed or malformed response also leaves existing findings for the whole batch unchanged; other batches can still complete. Incomplete runs do not advance the scheduled evaluation date. Reevaluation of unchanged content preserves ignored categories, and a successful evaluation removes categories that no longer have findings. Removing or reconfiguring the add-on clears its findings. Evaluator metadata is internal and cannot be edited through the API; the add-on configuration uses the existing 附加组件 permissions and validation.
自动化¶
Added in version 2026.10.
- 附加组件 ID:
weblate.automation.automation- 配置:
workflow工作流
以 YAML 或 JSON 格式输入自动化定义。
- 触发器:
运行带条件和分支的井然有序的翻译操作。
Install this add-on on a component, category, project, or site. Inherited instances run separately for each component. Multiple instances can be installed. Configuring, previewing, and running an automation requires the usual add-on management permission. Saving its configuration does not execute it.
Enter YAML or JSON in Workflow. Use Preview without changes to validate it and inspect planned actions, then Run now for real execution. Results appear in the add-on activity log.
参见
工作流定义 for the script definition and reference.
Cookbook for complete examples.
机器翻译前对翻译记忆库的 在机器翻译前应用翻译记忆库。
自动翻译¶
- 附加组件 ID:
weblate.autotranslate.autotranslate- 配置:
mode自动翻译模式
可用选项:¶ suggest添加为建议
translate添加为译文
fuzzy添加为“需要编辑”
approved添加为已核准的译文
q查询
请注意,翻译所有字符串将丢弃所有现有的译文。
auto_source自动翻译的来源
可用选项:¶ others其他翻译部件
mt机器翻译
component部件
Enter a source component ID. With 30 or more eligible source components, a project/component path is also accepted. In that case, component and project operations also accept a component slug from the target project. Leave blank to use eligible components from each target component's project.
engines机器翻译引擎
threshold匹配分数阈值
- 触发器:
使用机器翻译或其他部件自动翻译字符串。
To control translation order, use the 自动化 add-on with a separate action for each pass. Follow the 在机器翻译前应用翻译记忆库 cookbook example to apply local translation memory first and send only the remaining strings to a machine translation service. Selecting multiple engines here uses 机器翻译和翻译记忆库服务的优先级; installation order of separate add-ons does not define an execution sequence.
JavaScript 本地化 CDN¶
Added in version 4.2.
- 附加组件 ID:
weblate.cdn.cdnjs- 配置:
threshold译文阈值
已翻译字符串的百分比必须达到多少才能让一种语言的翻译被包括进来。
css_selectorCSS 选择器
检测可本地化元素的 CSS 选择器。
cookie_name语言 Cookie 名称
存储语言偏好的 Cookie 的名称。
files从 HTML 文件中提取字符串
当前仓库或远程 URL 中要解析可翻译字符串的文件名列表。
- 触发器:
将译文发布到 JavaScript 或 HTML 本地化中使用的内容分发网络。
可以用于本地化静态 HTML 网页,或者在 JavaScript 代码中加载本地化文件。
为你的部件生成一个唯一的 URL,你可以将其包含在 HTML 页面中以本地化它们。详情见 使用 Weblate CDN 翻译 HTML 和 JavaScript。
备注
此附加组件需在 Weblate 服务器上进行附加配置。LOCALIZE_CDN_PATH 配置生成的文件(在文件系统中)的写入位置,LOCALIZE_CDN_URL 定义从何处提供这些文件(URL)。Weblate 本身不提供这些文件,你必须设置外部源(通常使用 CDN 服务)。
此附加组件在 Hosted Weblate 上配置并通过 https://weblate-cdn.com/ 提供文件。
翻译文件 CDN¶
Added in version 2026.5.
将译文发布到内容分发网络。
Publishes translation files without converting them to another format. Files
are written below the add-on specific CDN directory and served from
LOCALIZE_CDN_URL/<add-on UUID>/. Single-file translations use the language
code and original file extension, for example cs.json or de.po.
Multi-file translations are served below the language code using paths relative
to the translation directory. Monolingual components include the source
language file, while bilingual components publish only target-language files.
See 语言本地化内容分发网络 for secure serving guidance.
Kotlin SDK CDN¶
Added in version 2026.10.
- 附加组件 ID:
weblate.cdn.kotlin- 配置:
maximum_age最大构建年龄(天)
在版本首次注册指定天数后报废版本。重新注册版本不会延长其寿命。
maximum_versions最多保留版本数
所有包名最多保留几个版本。当达到此限制或最大年龄时将报废一个版本。
- 触发器:
发布已注册 Kotlin SDK 版本的 Android 字符串和复数资源。
警告
The Kotlin SDK is available as an alpha release. No compatibility is guaranteed until the final Kotlin SDK is released. Endpoints, build metadata, CDN manifests, and generated resource formats may change without backward compatibility.
Install Kotlin SDK CDN on an Android string-resource component to
publish translations for builds registered by the Kotlin SDK. Configure
LOCALIZE_CDN_URL and LOCALIZE_CDN_PATH first. CDN output is
public, including translations from private components. Manifests expose the
application package name and version code. ARSC files expose published resource
names and their submitted IDs alongside translated text. Do not treat the
uploaded resource mapping as confidential; enable publication only when this
disclosure is intended. Registration and status API access remains permission-controlled.
Copy the Gradle plugin configuration from the add-on configuration page. It
includes the Weblate server URL, public CDN URL, project slug, and component
path (with any category path URL-encoded). Replace the placeholder with a
project-scoped API token whose permissions allow editing the component. Project
administrators can create one in the project's API access tab; see
项目访问令牌.
Keep that token in the build environment, not in the application. The add-on's
API tab shows the API base URL; submit build metadata to its builds/
endpoint. See
Kotlin SDK builds for the request and response format.
For Gradle plugin and library setup, see Android 的 Kotlin SDK.
The add-on matches resource names and types from registered builds to current component translations. Strings, plurals, and Android styled text are supported. String arrays and resource references are not generated. Untranslated entries, read-only entries, and incomplete plural resources are omitted; applications retain their bundled values. Unsupported styling fails publication; the previous successful publication remains available.
Resource IDs must describe the final installed build. Uploading an identical mapping again is harmless; a different mapping for the same package and version is rejected. Old builds receive current translations by name, including after source text or formatting arguments change. Maintainers are responsible for compatibility with older application code.
生命周期设置¶
Maximum build age (days) defaults to 365 and accepts 1 through 730, measured from the first registration. Repeated uploads do not extend it.
Maximum retained versions defaults to 20 and accepts 1 through 100, counted across all package names. One additional unpublished replacement is allowed. New registrations can retire older unpublished replacements. Published builds are retired for this limit only after a replacement is published. Failed replacements preserve existing publications; maximum-age expiry still applies independently.
Either limit retires a build and immediately clears its metadata. Lightweight retired records are deleted on cleanup after 24 hours and successful manifest removal; their package/version identifiers can then be registered again. Failed or interrupted manifest removals are retried hourly. Until removal succeeds, the registration and its referenced artifacts are retained, and the files may remain publicly accessible. Resource mappings are immutable only while their registration records remain.
Each add-on permits at most 1000 registration records, including retired records. New registrations exceeding this limit return HTTP 409 until cleanup frees capacity; identical retries remain accepted. Metadata is bounded by the 5 MiB upload limit and maximum retained version count plus one replacement, without a separate byte quota. Limits are enforced during registration and scheduled cleanup.
Superseded artifacts are deleted on cleanup after a fixed 24-hour window. All artifact files, including superseded files and incomplete publication output, count towards hard limits of 5 GiB and 10000 files per add-on. The larger artifact allowance accommodates translated text and multiple locales; it does not guarantee capacity for every locale or build combination. Shared artifacts count only once. Publications exceeding either limit fail before writing new artifacts and preserve the previous manifest. Neither the window nor these limits are configurable. Limit manifest caching as described below.
Compilation stages one locale at a time on disk. A per-locale conservative encoded text and styling estimate exceeding 64 MiB fails publication.
Preparation additionally requires up to 5 GiB of temporary disk space per
publication job, separate from the published artifact allowance. Temporary
files contain staged ARSC output, shared by versions with identical resource mappings.
They are stored below LOCALIZE_CDN_PATH. Configure the server to
deny access to .kotlin-sdk-staging as described in
语言本地化内容分发网络 before enabling this add-on.
Manifest replacement follows the database commit. Failed or interrupted writes are retried by subsequent publication jobs, with artifacts for both the old and pending manifest protected until replacement succeeds.
Uninstalling the add-on attempts to remove its published files from the CDN origin immediately. Failed or interrupted removals are retried hourly; files may remain publicly accessible until cleanup succeeds. Removal does not revoke copies already cached or downloaded by clients.
Publication and cleanup run asynchronously after build registration, component updates, translation commits and removals, and during daily add-on processing. Failures appear in the add-on activity log and registration status. Previous successful publications remain available when replacement generation fails. If the component stops using the Android resource format, hourly maintenance retires its publications. The normal artifact retention window still applies.
CDN 客户合同¶
Each build has a stable manifest at
<CDN base>/<packageName>/<versionCode>/manifest.json. The version 1 manifest
contains schemaVersion, packageName, versionCode, and locales.
Locale keys are Weblate language codes. Each locale contains a relative url,
sha256, and byte size for its ARSC artifact. Resolve relative URLs against
the manifest URL. Artifact contents do not change after publication.
The manifest has a JSON Schema.
Configure the CDN origin to cache manifests for at most one hour (for example,
Cache-Control: public, max-age=3600), and artifact files with
Cache-Control: public, max-age=31536000, immutable. Artifact files may use
application/octet-stream. Configure these headers on the CDN server.
Translation updates and retirements can take up to one hour to reach clients.
Use Cache-Control: no-cache when immediate revalidation is preferred.
The fixed 24-hour artifact retention window exceeds the manifest cache lifetime.
The Kotlin SDK should validate artifact length and hash, cache successful downloads locally, and load them with Android's resources-loader API on API 30 or newer. A missing manifest, missing locale, or download failure must preserve bundled resources. Retired manifests return 404 at the origin; cached copies can remain usable until they expire. Hashes detect corrupted or mismatched content; authentication relies on HTTPS and the configured CDN.
移除空白字符串¶
Added in version 4.4.
从翻译文件中删除没有译文的字符串。
使用此方法可以使翻译文件中不存在任何空字符串(例如,如果您的本地化库将它们显示为缺失,而不是退回到源字符串)。
清理翻译文件¶
更新所有翻译文件以匹配单语言译文模版文件。对于大多数文件格式来说,这意味着移除译文模版文件中不再出现的旧翻译条目。
对于包含翻译字符串外的其他内容格式(如 HTML 文件、Windows RC 文件 或 OpenDocument 格式),这也会使翻译文件与基文件同步。
For a one-time cleanup of a single translation file, use Cleanup unused in 仓库维护 on that translation instead of installing the add-on.
添加缺少的语言¶
确保对一个项目内所有部件使用一致的一组语言。
备注
不考虑分享自其他项目的部件。
每隔 24 小时,和在 Weblate 中加入新语言时,会检查一次缺失的语言。
不像其他多数附加组件,这个附加组件影响整个项目。
提示
用 自动翻译 自动翻译新添加的字符串。
部件发现¶
- 附加组件 ID:
weblate.discovery.discovery- 配置:
match用于匹配翻译文件的正则表达式
正则表达式必须为部件定义一个命名组。匹配翻译文件时也为语言定义一个命名组。设置了文件掩码时,略去语言,匹配单语言基文件或新的基文件。
file_format文件格式
name_template自定义部件名称
使用 Django 模板语法。此模板必须包含 {{ component }}。
base_file_template指定单语种译文模版文件名
双语翻译文件请留空。设置后,此模板必须包括 {{ component }}。
new_base_template为新的翻译条目指定翻译模版文件
请指定模板文件,新语言的翻译文档将会套用该模板。对于 gettext 格式,请选择 .pot 文件。此模板必须包含 {{ component }}。
intermediate_template中间语言文件
中间翻译文件的文件名。在大多数情况下,这是开发者提供的翻译文件,用于创建实际的源字符串。此模板必须包含 {{ component }}。
filemask_template定义文件掩码
留空直接匹配翻译文件。设置好后,发现匹配单语言基文件或新的基文件并将此模板用作文件掩码。包含一个语言通配符和 {{ component }},比如 locale//{{ component }}.po 或 docs/{{ component }}_.md。
language_regex语言筛选
扫描文件掩码时用于筛选翻译文件的正则表达式。
copy_addons将主部件的附加组件克隆到新创建的部件
remove删除不存在文件的部件
- 触发器:
根据版本控制系统中文件更改的情况来自动添加或删除项目部件。
此匹配使用允许复杂配置的正则表达式完成,但需要知晓一些正则表达式的知识。匹配翻译文件的正则表达式通常必须包含两个命名组以匹配部件和语言。从单语言基文件或新的基文件创建部件时,略去语言组,匹配那个源文件。所有正则表达式的命名组均可用作模板字段中的变量。
“发现”要求¶
要成功发现部件,配置必须做下面的所有东西:
正则表达式必须定义
component命名组。匹配的翻译文件还需要一个language命名组。用于命名或定位每一个部件文件的模板字段必须包含
{{ component }},因此渲染的值实际上为每个发现的部件更改。对于单语格式,部件必须包含一个匹配
base_file_template的文件并至少一个匹配match的翻译文件,除非你设置文件掩码(见下方)。
发现没有翻译文件的部件¶
Set Define the file mask to discover components from a monolingual base or new base file alone, even when no translation files exist yet. In that mode:
Configure Regular expression to match translation files against to match the monolingual base or new base file, and omit the
languagegroup. Keep full control over thecomponentcapture, for examplelocale/(?P<component>[^/]+)\.potordocs/(?P<component>[^/_]+)\.md.Fill Define the file mask with a path that includes both a language wildcard and
{{ component }}, for examplelocale/*/{{ component }}.poordocs/{{ component }}_*.md.Keep using the other filename templates with any named groups from the match expression.
有效示例:news_<lang>.md¶
这是一个常见的基于文件名的语言变体布局:
docs/news_en.mddocs/news_cs.mddocs/guide_en.md
使用起始点 基于文件名的语言变体 预设,然后选择匹配的文件格式并审核填充的值。
- 正则表达式:
(?:(?P<path>.*/))?(?P<component>.+?)_(?P<language>[A-Za-z]{2,3}(?:[_-][A-Za-z0-9]+)*)\.(?P<extension>[^/.]+)- 部件名称:
{{ component }}- 发现的文件掩码:
docs/news_*.mddocs/guide_*.md
在这个示例中,{{ component }} 解析为语言前缀前的基名称,因此 docs/news_en.md、docs/news_pt_BR.md 和 docs/news_pt-BR.md 均成为 news 部件。
您可以在所有文件名字段中使用 Django 模板标记,例如:
{{ component }}解析自
component匹配组的部件名{{ component|title }}首字母大写的部件文件名
{{ path }}: {{ component }}来自正则表达式的自定义匹配群
点击 保存 后,将显示匹配部件的预览,您可以从中检查配置是否真正符合您的需求:
部件发现示例¶
上面的有效示例涵盖最常见的基于文件名的变体布局。下面的示例显示你可以匹配的其他仓库结构。
每种语言一个文件夹¶
每种语言各使用一个文件夹并在其中包含相应部件的翻译文件。
- 正则表达式:
(?P<language>[^/.]*)/(?P<component>[^/]*)\.po- 匹配文件:
cs/application.pocs/website.pode/application.pode/website.po
Gettext 语言环境布局¶
存储 gettext PO 文件时使用常用结构。
- 正则表达式:
locale/(?P<language>[^/.]*)/LC_MESSAGES/(?P<component>[^/]*)\.po- 匹配文件:
locale/cs/LC_MESSAGES/application.polocale/cs/LC_MESSAGES/website.polocale/de/LC_MESSAGES/application.polocale/de/LC_MESSAGES/website.po
复杂文件名¶
同时在文件名处使用部件名和语言名。
- 正则表达式:
src/locale/(?P<component>[^/]*)\.(?P<language>[^/.]*)\.po- 匹配文件:
src/locale/application.cs.posrc/locale/website.cs.posrc/locale/application.de.posrc/locale/website.de.po
重复的语言码¶
在路径和文件名中使用的语言名称。
- 正则表达式:
locale/(?P<language>[^/.]*)/(?P<component>[^/]*)/(?P=language)\.po- 匹配文件:
locale/cs/application/cs.polocale/cs/website/cs.polocale/de/application/de.polocale/de/website/de.po
分开的 Android 字符串¶
Android 资源字符串,分成几个文件。
- 正则表达式:
res/values-(?P<language>[^/.]*)/strings-(?P<component>[^/]*)\.xml- 匹配文件:
res/values-cs/strings-about.xmlres/values-cs/strings-help.xmlres/values-de/strings-about.xmlres/values-de/strings-help.xml
匹配多个路径¶
有 Java 属性翻译的多模块 Maven 项目。
- 正则表达式:
(?P<originalHierarchy>.+/)(?P<component>[^/]*)/src/main/resources/ApplicationResources_(?P<language>[^/.]*)\.properties- 部件名称:
{{ originalHierarchy }}: {{ component }}- 匹配文件:
parent/module1/submodule/src/main/resources/ApplicationResources_fr.propertiesparent/module1/submodule/src/main/resources/ApplicationResource_es.propertiesparent/module2/src/main/resources/ApplicationResource_de.propertiesparent/module2/src/main/resources/ApplicationResource_ro.properties
提示
部件发现附加组件使用 Weblate 内部网址。这是在多个部件之间共享版本控制系统设置的便捷方式。链接的部件使用主部件的本地仓库,其设置方法是将 weblate://project/main-component 填入各部件的 源代码仓库 字段(在 操作 ↓ 设置 ↓ 版本控制系统)。这也节省了配置和系统资源的时间。
提示
用 添加缺少的语言 确保新部件包含完整的可翻译语言集。
Fedora Messaging¶
Added in version 5.15.
- 附加组件 ID:
weblate.fedora_messaging.publish- 配置:
amqp_urlAMQP 代理 URL
要连接的 AMQP 代理 URL.
topic_prefix主题前缀
加到生成的消息主题前的可选前缀。
publish_timeout发布超时
代理传输确认等待秒数。
connection_attempts连接尝试
尝试连接代理的次数。
retry_delay重试延迟时间
两次连接尝试间相隔的秒数。
ca_certCA 证书 bundle (PEM)
只粘贴 PEM 证书块,每个证书块以 "-----BEGIN CERTIFICATE-----" 开头,以 "-----END CERTIFICATE-----" 结尾。
client_key客户端密钥(PEM)
粘贴单个未加密的 PEM 私钥块。不支持加密的私钥。
client_cert客户端证书(PEM)
只粘贴以 "-----BEGIN CERTIFICATE-----" 开头的 PEM 证书块;不粘贴来自 "openssl x509 -text" 的输出。
event_filter更改触发事件
Choose which change events should trigger this add-on. 更改触发事件
events已选中更改事件
- 触发器:
发送通知到兼容 Fedora Messaging 的 AMQP 交换。
Fedora Messaging 是基于 AMQP 的发布者,用于处理 Weblate 中发生的所有更改。您可以使用它来挂钩 Weblate 中发生的更改的附加服务。
消息标题¶
所有消息均有 weblate.<action>.<project>.<category...>.<component>.<translation> 标题。配置后,用单点分隔符将 topic_prefix 呈现给此主题,比如 org.fedoraproject.weblate.project_backed_up.website 。使用下划线而非空格连接的小写英语文本表示动作,例如 resource_updated ,全部操作标识符见 已选中更改事件。剩余部分匹配 Weblate 对象路径片段。
For example, a project backup event for the website project uses
weblate.project_backed_up.website. A translation change in the website
project, frontend component, and Czech translation uses
weblate.translation_changed.website.frontend.cs. The same change in the
frontend component inside the parent and child categories uses
weblate.translation_changed.website.parent.child.frontend.cs.
消息正文¶
正文由下列字段组成(假定事件中有这些字段):
change_id更改的数字 ID
action更改的冗长名称。
timestampISO 格式的时间戳
target更改的新值(如字符串的新翻译)
old更改的旧值(如字符串之前额翻译)
source源字符串.
url查看相关对象的绝对 URL。
author作者的用户名(进行接受建议等操作时,可以不同于用户名)
user临时用户名
project项目标识串
component部件标识串
translation翻译语言代码
消息标头¶
有几个额外字段也可用于路由:
action更改的冗长名称。
project项目标识串
component部件标识串
示例消息¶
仓库合并事件:
{
"id": 1,
"action": "Merged repository",
"timestamp": "2017-06-15T11:30:47.325000+00:00",
"url": "http://example.com/projects/test/test/",
"component": "test"
}
新源字符串事件:
{
"id": 2,
"action": "New source string",
"timestamp": "2017-06-15T11:30:47.372000+00:00",
"url": "http://example.com/translate/test/test/cs/?checksum=6412684aaf018e8e",
"component": "test",
"translation": "cs",
"source": ["Hello, world!\n"]
}
资源更新事件:
{
"id": 6,
"action": "Resource update",
"timestamp": "2017-06-15T11:30:47.410000+00:00",
"url": "http://example.com/projects/test/test/cs/",
"project": "test",
"component": "test",
"translation": "cs"
}
{
"id": 7,
"action": "Resource update",
"timestamp": "2017-06-15T11:30:47.510000+00:00",
"url": "http://example.com/projects/test/test/de/",
"project": "test",
"component": "test",
"translation": "de"
}
{
"id": 8,
"action": "Resource update",
"timestamp": "2017-06-15T11:30:47.595000+00:00",
"url": "http://example.com/projects/test/test/it/",
"project": "test",
"component": "test",
"translation": "it"
}
项目删除事件:
{
"id": 9,
"action": "Removed project",
"timestamp": "2019-10-17T15:57:08.559420+00:00",
"target": "test",
"user": "testuser"
}
新贡献者事件:
{
"id": 11,
"action": "New contributor",
"timestamp": "2019-10-17T15:57:08.759960+00:00",
"url": "http://example.com/translate/test/test/cs/?checksum=6412684aaf018e8e",
"author": "testuser",
"user": "testuser",
"project": "test",
"component": "test",
"translation": "cs",
"source": ["Hello, world!\n"]
}
新译文事件:
{
"id": 12,
"action": "New translation",
"timestamp": "2019-10-17T15:57:08.772591+00:00",
"url": "http://example.com/translate/test/test/cs/?checksum=6412684aaf018e8e",
"target": ["Ahoj svete!\n"],
"author": "testuser",
"user": "testuser",
"project": "test",
"component": "test",
"translation": "cs",
"source": ["Hello, world!\n"]
}
批量编辑¶
- 附加组件 ID:
weblate.flags.bulk- 配置:
q查询
state要设置的状态
可用选项:¶ -1请勿更改
10需要编辑
11需要编辑(需要重写)
12需要编辑(需要检查)
20已翻译
30已核准
add_flags要添加的原文标记——所有语言
remove_flags要删除的原文标记——所有语言
add_translation_flags要添加的译文标记——匹配的译文
只应用到匹配的译文,排除源字符串。
remove_translation_flags要删除的翻译标记——匹配的译文
移除本地设置的标记。继承的标记仍然有效。
add_labels要添加的标签——所有语言
remove_labels要删除的标签——所有语言
- 触发器:
批量编辑标记、标签或字符串状态。
示例:
搜索查询 |
|
|---|---|
要添加的标签 |
近期 |
搜索查询 |
|
|---|---|
要添加的翻译标记 |
|
将未更改的译文标记为“需要重写”¶
- 附加组件 ID:
weblate.flags.same_edit- 配置:
此附加组件无配置。
- 触发器:
每当从版本控制系统导入新的可翻译字符串并与源字符串匹配时,就会在 Weblate 中标记为需要重写。对于包含未翻译字符串的源字符串的文件格式尤其有用。
参见
将新的源字符串标记为“需要检查”¶
- 附加组件 ID:
weblate.flags.source_edit- 配置:
此附加组件无配置。
- 触发器:
每当一个新的源字符串从版本控制系统中导入时,它将在 Weblate 中被标记为需要检查。这样就可以简单地筛选并编辑开发者编写的源字符串。
参见
将新译文标记为“需要重写”¶
- 附加组件 ID:
weblate.flags.target_edit- 配置:
此附加组件无配置。
- 触发器:
每当一个新的可翻译字符串从版本控制系统中导入时,它将在 Weblate 中被标记为需要重写。这样就可以简单地筛选并编辑开发者创建的翻译。
参见
将仓库中更新的译文标记为“需要重写”¶
- 附加组件 ID:
weblate.flags.target_repo_update- 配置:
此附加组件无配置。
- 触发器:
每当一个字符串翻译在版本控制系统中被更改后,它会在 Weblate 中被标记为需要重写。如果翻译文件经常被手动更新或由外部服务更新,此功能尤其有用。
参见
用原文填充只读字符串¶
Added in version 4.18.
将源字符串内容用作只读字符串的译文。
统计数据生成器¶
- 附加组件 ID:
weblate.generate.generate- 配置:
scope输出作用域
可用选项:¶ translation每个翻译一个文件
component每个部件一个文件
filename所生成文件的名称
template所生成文件的内容
- 触发器:
生成一个包含关于翻译状态详细信息的文件。
你可以在文件名和内容中使用 Django 模板,详细的标记说明请参见 模板标记。
例如为每个翻译生成一个摘要文件:
- 所生成文件的名称
locale/{{ language_code }}.json- 内容
{ "language": "{{ language_code }}", "strings": "{{ stats.all }}", "translated": "{{ stats.translated }}", "last_changed": "{{ stats.last_changed }}", "last_author": "{{ stats.last_author }}", }
部件级输出¶
Set Output scope to One file per component to maintain one locale list or statistics file for the entire component. The default, One file per translation, preserves existing configurations.
Component output is generated on installation and configuration changes. It is updated when translations are committed, languages are added or removed, and component files are reloaded. Language metadata changes are included on the next such update or when the add-on is reconfigured. Unchanged output does not create a new commit.
Both modes support component and project variables in filenames and content.
In component mode, the content additionally receives translations, ordered
by repository language code. Each item provides:
language_code:仓库中所用语言代码。language-- 语言的英语名。language_native_name: the name translated into its own language using Weblate's catalogs, with an English fallback when unavailable.language_direction:ltrorrtl.filenameandurl: the translation filename and Weblate URL.is_source:是否是部件的原文翻译。stats: the same statistics available in translation mode.
The source translation is included. Templates can exclude it using
{% if not item.is_source %}. Statistics use Weblate's completion semantics.
Custom language names are retained; there is no external locale-data lookup.
For example, generate locales.json for a website:
[
{% for item in translations %}
{
"code": {{ item.language_code|json }},
"file": {{ item.filename|json }},
"name": {{ item.language_native_name|json }},
"dir": {{ item.language_direction|json }}
}{% if not forloop.last %},{% endif %}
{% endfor %}
]
或生成程序的 languages.py:
names = {
{% for item in translations %}
{{ item.language_code|python }}: {{ item.language_native_name|python }},
{% endfor %}
}
completeness = {
{% for item in translations %}
{{ item.language_code|python }}: {{ item.stats.translated_percent|python }},
{% endfor %}
}
The json and python filters serialize complete values, including string
quotes and escaping. Do not add quotes around their output. They also support
lists and dictionaries; {{ translations|json }} exports all available data.
Dates and times are serialized as ISO-formatted strings.
参见
用原文预填充译文¶
Added in version 4.11.
用源字符串填充翻译字符串。
部件中所有未翻译的字符串将被填充为源字符串,并被标记为需要编辑。当你的翻译文件中不能兼容空字符串时请使用这个功能。.. AUTOGENERATED START: weblate.generate.pseudolocale .. 此部分由 ./manage.py list_addons 自动生成。不要手动编辑。
假语言环境(Pseudolocale)生成¶
Added in version 4.5.
- 附加组件 ID:
weblate.generate.pseudolocale- 配置:
source源字符串
target目标译文
此翻译中的所有字符串都将被覆盖
prefix前置静态文本
var_prefix前置变量文本
suffix后置静态文本
var_suffix后置变量文本
var_multiplier变量文本乘数
根据源字符串的长度确定变量文本的重复次数。
include_readonly包含只读字符串
- 触发器:
通过向源字符串添加前缀和后缀自动生成翻译。
伪 locale 对于查找未准备好进行本地化的字符串很有用。这是通过修改所有可翻译的源字符串来实现的,使得在用伪 locale 语言运行应用程序时很容易发现未修改的字符串。
也可以查找其本地化对应项可能不适合布局的字符串。
使用可变部分可以寻找那些在本地化后可能不适合用户界面的字符串-它根据源字符串的长度来扩展文本。可变文本是以文本的长度乘以乘数来重复的。例如 Hello world 带可变文本 _ 和变量乘数1将变为 Hello world___________ - 即该可变文本对源字符串中的每个字符都重复一次。
将使用以下模式生成字符串:
前置静态文本 前置变量文本 源字符串 后置变量文本 后置静态文本
提示
可以使用真正的语言进行检测,但在 Weblate 中有专用的假语言环境——en_XA 和 ar_XB。
提示
您可以使用此附加组件来开始翻译到现有语言或类似语言的新语言环境。将翻译添加到部件后,请遵循附加组件。示例:如果您有 fr 的翻译并想开始翻译 fr_CA,只需将 fr 设置为源,将 fr_CA 设置为目标,并将前缀和后缀留空。
一旦您有新的翻译填重,请卸载附加组件,以防止 Weblate 更改复制后的翻译。
更新“配置文件”中的 ALL_LINGUAS 变量¶
当添加或删除译文时,更新“configure”、“configure.in”或“configure.ac”文件中的 ALL_LINGUAS 变量。
添加或删除翻译时,更新 configure、configure.in 或任何 configure.ac 文件中的 ALL_LINGUAS 变量。
自定义 gettext 输出¶
Removed in version 5.13: 被 文件格式参数 替代。
更新 gettext 模板(Django)¶
Added in version 5.17.
用 Django 的内置 makemessages 命令更新 gettext 模板。
This add-on updates the template configured in 新语种的翻译模版. It is available for gettext PO components, and the component must define a template for new translations.
The selected update frequency applies to automatic runs after repository refreshes. Installing or reconfiguring the add-on runs it immediately, and manual runs from add-on management or the API also bypass the frequency schedule. After a successful update, Weblate commits the changed template and reloads source strings.
The template update does not update translation PO files by itself. Keep 更新 PO 文件以匹配 POT 文件 (msgmerge) installed when translation files should follow template changes automatically. The install form for this add-on can install that add-on, but existing add-on settings do not show that installation option again.
Django 要求¶
This add-on requires xgettext and msguniq. It runs Weblate's internal extraction wrapper for Django messages instead of invoking a project's manage.py makemessages, so it does not load project Django settings or applications.
The template for new translations must use the django or djangojs
domain. Supported template names are django.pot, djangojs.pot,
django.po, and djangojs.po. Weblate infers the source directory
from the template path and skips repository locale directories while extracting.
更新 LINGUAS 文件¶
添加或删除译文时更新 LINGUAS 文件。
更新 POT 文件(Meson)¶
Added in version 5.17.
- 附加组件 ID:
weblate.gettext.meson- 配置:
interval更新频率
刷新部件时附加组件更新 POT 文件的频率。
可用选项:¶ daily每天
weekly每周
monthly每月
normalize_header正常化 POT 标头
更新 gettext 标头并替换占位符 POT 注释。
location_mode原文位置
选择提取如何将源位置写入 POT 文件。使用这个在模板中保留位置同时在翻译的 PO 文件中省去它们。
可用选项:¶ file使用文件格式设置
keep提取位置到 POT 文件
omit不提取位置
data_dirsITS数据目录
包含一个自身子目录的以换行符分割的与仓库相关的目录,如 po for po/its。较早目录覆盖较晚的目录和捆绑的规则。
comment_mode代码注释
选择 xgettext 是不提取注释、提取所有注释,还是只提取特定标签标记的注释。
可用选项:¶ off不提取注释
all提取所有注释
tagged提取带标签的注释
comment_tag注释标签
使用标签注释模式时为提取注释而传递给 xgettext 的标签。
checksxgettext 检查
要为提取的消息而启用的额外的 xgettext 验证检查。
可用选项:¶ ellipsis-unicodeellipsis-unicode
space-ellipsisspace-ellipsis
quote-unicodequote-unicode
bullet-unicodebullet-unicode
keyword附加关键词
用 --keyword 传递给 xgettext 换行符隔开的附加关键词。
keyword_exclusive排他性地使用关键词
When enabled, passes
--keywordwithout a value to xgettext before the additional keyword, disabling all default keywords so that only the keyword specified above is recognized.presetMeson 预设
内置的 xgettext 变量预设匹配 Meson gettext 集成。GLib 预设添加键盘和 Meson 的 gettext 助手所用的格式标记选项。
可用选项:¶ glibGLib
- 触发器:
用 Meson gettext 规范更新 gettext 模板。
This add-on updates the template configured in 新语种的翻译模版. It is available for gettext PO components, and the component must define a template for new translations.
The selected update frequency applies to automatic runs after repository refreshes. Installing or reconfiguring the add-on runs it immediately, and manual runs from add-on management or the API also bypass the frequency schedule. After a successful update, Weblate commits the changed template and reloads source strings.
The template update does not update translation PO files by itself. Keep 更新 PO 文件以匹配 POT 文件 (msgmerge) installed when translation files should follow template changes automatically. The install form for this add-on can install that add-on, but existing add-on settings do not show that installation option again.
Meson 要求¶
This add-on requires xgettext; it does not invoke Meson. It follows
Meson gettext conventions by reading POTFILES or POTFILES.in
from the gettext directory and passing the GLib keyword and format-flag preset
to xgettext.
The gettext directory is the directory containing the template configured in
新语种的翻译模版. It must contain meson.build and
POTFILES or POTFILES.in. A Meson project meson.build
must be present in that directory or one of its parent directories. If both
POTFILES and POTFILES.in exist, POTFILES is used.
An adjacent POTFILES.skip excludes listed source files from extraction.
Configure this add-on from the existing Meson gettext setup. In most Meson
projects, the gettext directory is po/, the template is named after the
gettext domain, and po/meson.build calls Meson's gettext helper. Use the
same template path in 新语种的翻译模版, for example
po/example.pot, and keep POTFILES or POTFILES.in next to
that meson.build file.
Weblate does not read the source file list from meson.build. It uses
POTFILES or POTFILES.in, matching Meson's gettext convention.
When the Meson project uses a non-default gettext directory or domain, mirror
that layout in the component template path.
生成 MO 文件¶
- 附加组件 ID:
weblate.gettext.mo- 配置:
path生成的 MO 文件的路径
如未指定,将使用 PO 文件对应的位置。
fuzzy包括需要编辑的字符串
需要编辑的字符串(fuzzy)通常无法直接被用作译文。
- 触发器:
为每个变更的 PO 文件自动生成 MO 文件。
生成的 MO 文件的位置可以定制化,并且其字段使用 模板标记。
备注
如果译文被移除,其 PO 文件将从仓库中被删除,但此附加组件生成的 MO 文件不会被删。必须手动从上游移除 MO 文件。
更新 PO 文件以匹配 POT 文件 (msgmerge)¶
在 5.13 版本发生变更: 设置 配置已移至 文件格式参数。
使用 msgmerge 更新所有的 PO 文件(由“文件掩码”配置)以匹配 POT 文件(由“新翻译模板”配置)。
处理 POT 模板文件有更新(有新字符串或现有字符串有更改)的 gettext PO 文件时,该附加组件必不可少。当 POT 文件在仓库中更新时,该附加组件会自动将其更改合并入所有语言的 PO 文件,确保:
新的可翻译字符串出现在所有语言中
删除的字符串被标记为过时
已修改字符串被标记为需要审核(fuzzy)
多数 msgmerge 命令行选项可通过文件格式参数配置进行设置。启用 po_remove_obsolete 参数在保存 PO 文件时删除陈旧的 #~ 条目。
参见
msgmerge
更新 POT 文件(Sphinx)¶
Added in version 5.17.
- 附加组件 ID:
weblate.gettext.sphinx- 配置:
interval更新频率
刷新部件时附加组件更新 POT 文件的频率。
可用选项:¶ daily每天
weekly每周
monthly每月
normalize_header正常化 POT 标头
更新 gettext 标头并替换占位符 POT 注释。
location_mode原文位置
选择提取如何将源位置写入 POT 文件。使用这个在模板中保留位置同时在翻译的 PO 文件中省去它们。
可用选项:¶ file使用文件格式设置
keep提取位置到 POT 文件
omit不提取位置
filter_mode筛选
在 Sphnix 提取后可以选择删除对翻译无用的字符串。
可用选项:¶ none无
weblate_docsWeblate 文档
- 触发器:
用 Sphinx 的 gettext 构造工具在不加载项目配置情况下更新 gettext 模板。
This add-on updates the template configured in 新语种的翻译模版. It is available for gettext PO components, and the component must define a template for new translations.
The selected update frequency applies to automatic runs after repository refreshes. Installing or reconfiguring the add-on runs it immediately, and manual runs from add-on management or the API also bypass the frequency schedule. After a successful update, Weblate commits the changed template and reloads source strings.
The template update does not update translation PO files by itself. Keep 更新 PO 文件以匹配 POT 文件 (msgmerge) installed when translation files should follow template changes automatically. The install form for this add-on can install that add-on, but existing add-on settings do not show that installation option again.
Sphinx 要求¶
This add-on requires sphinx-build, provided by the sphinx
installation extra. The template for new translations must be a .pot
file below a locales directory. The directory before locales is
used as the Sphinx source directory and must contain conf.py.
Extraction uses Weblate's bundled Sphinx configuration and does not load the project configuration. Weblate runs the Sphinx gettext builder, normalizes source references to paths relative to the source directory, and copies the generated template back to the configured template path.
更新 POT 文件(xgettext)¶
Added in version 5.17.
- 附加组件 ID:
weblate.gettext.xgettext- 配置:
interval更新频率
刷新部件时附加组件更新 POT 文件的频率。
可用选项:¶ daily每天
weekly每周
monthly每月
normalize_header正常化 POT 标头
更新 gettext 标头并替换占位符 POT 注释。
location_mode原文位置
选择提取如何将源位置写入 POT 文件。使用这个在模板中保留位置同时在翻译的 PO 文件中省去它们。
可用选项:¶ file使用文件格式设置
keep提取位置到 POT 文件
omit不提取位置
data_dirsITS数据目录
包含一个自身子目录的以换行符分割的与仓库相关的目录,如 po for po/its。较早目录覆盖较晚的目录和捆绑的规则。
comment_mode代码注释
选择 xgettext 是不提取注释、提取所有注释,还是只提取特定标签标记的注释。
可用选项:¶ off不提取注释
all提取所有注释
tagged提取带标签的注释
comment_tag注释标签
使用标签注释模式时为提取注释而传递给 xgettext 的标签。
checksxgettext 检查
要为提取的消息而启用的额外的 xgettext 验证检查。
可用选项:¶ ellipsis-unicodeellipsis-unicode
space-ellipsisspace-ellipsis
quote-unicodequote-unicode
bullet-unicodebullet-unicode
keyword附加关键词
用 --keyword 传递给 xgettext 换行符隔开的附加关键词。
keyword_exclusive排他性地使用关键词
When enabled, passes
--keywordwithout a value to xgettext before the additional keyword, disabling all default keywords so that only the keyword specified above is recognized.input_mode输入源
选择 xgettext 应该从 glob 模式还是从 POTFILES/POTFILES.in 清单读取源文件。
可用选项:¶ patterns源文件模式
potfilesPOTFILES 清单
languagexgettext 语言
传递给 xgettext 的编程语言,如 Python 或 C。留空让 xgettext 从文件扩展名进行猜测。
source_patterns源文件模式
换行符分隔的相对于仓库的 glob 模式,针对使用 xgetext 提取的文件。
potfiles_pathPOTFILES 路径
POTFILES 或 POTFILES.in. 的相对于仓库的路径。相对于仓库根目录解析条目。如果在清单文件旁边,那么 POTFILES.skip 不提取所列文件。
- 触发器:
用 xgettext 更新所选源文件的 gettext 模板。
This add-on updates the template configured in 新语种的翻译模版. It is available for gettext PO components, and the component must define a template for new translations.
The selected update frequency applies to automatic runs after repository refreshes. Installing or reconfiguring the add-on runs it immediately, and manual runs from add-on management or the API also bypass the frequency schedule. After a successful update, Weblate commits the changed template and reloads source strings.
The template update does not update translation PO files by itself. Keep 更新 PO 文件以匹配 POT 文件 (msgmerge) installed when translation files should follow template changes automatically. The install form for this add-on can install that add-on, but existing add-on settings do not show that installation option again.
xgettext 要求¶
This add-on requires xgettext. Configure either source file patterns
or a POTFILES / POTFILES.in manifest. Source file patterns are
repository-relative glob patterns and only matching repository files are passed
to xgettext.
Entries in POTFILES or POTFILES.in are resolved relative to the
repository root. They must be relative paths, stay inside the repository, and
point to existing files. Blank lines and lines starting with # are ignored.
If a POTFILES.skip file exists next to the manifest, its entries are
excluded from extraction.
Automatic repository refresh runs are skipped unless the changed files match the configured source patterns, match files listed in the manifest, change a watched manifest, or change the add-on configuration.
Start from the build-system extraction setup when configuring this add-on.
Autotools projects usually keep gettext inputs in po/POTFILES.in and
options such as the gettext domain and xgettext flags in
po/Makevars or related Makefile.am files. Use manifest mode
with the same POTFILES.in when its entries are plain repository-relative
source paths, and copy relevant extraction behavior into the add-on settings,
for example the language, comment extraction, checks, and additional keyword.
For other build systems, use the source list or extraction command they already
run as the source of truth. CMake, custom Makefiles, npm scripts, or project
specific extraction scripts often call xgettext directly or generate
an intermediate file list. Configure source patterns for simple layouts, or use
manifest mode when the project maintains a plain file list. If a build-system
manifest contains transformations or prefixes that are not file paths, convert
it to plain repository-relative paths before using it as POTFILES.
Mixed source formats and ITS rules¶
Leave xgettext language blank to extract messages from different
formats into the same POT. Include all inputs in the source patterns or
POTFILES, for example:
common/messages.py
qt/application.desktop
qt/application.policy
data/application.metainfo.xml
Desktop entries use the native xgettext parser. Weblate bundles ITS rules for Polkit policies, AppStream/MetaInfo, GSettings, GTK Builder, and Shared MIME Info. These rules are included in the Weblate package, including Docker installations; no additional system packages are required for these formats. The 更新 POT 文件(Meson) add-on uses the same rules.
Extraction follows upstream gettext and ITS behavior. In particular, desktop
extraction includes keys such as Name, GenericName, and Comment;
Polkit rules select description and message elements without filtering
by gettext-domain. Use untranslated policy sources: upstream Polkit rules
also select elements carrying xml:lang.
For custom XML formats or overrides, configure ITS data directories.
Enter one repository-relative directory per line, in priority order. Each must
contain an its/ subdirectory with .loc locating rules and .its
extraction rules. For example, enter po for po/its/example.loc and
po/its/example.its, or . for its/ at the repository root.
In API add-on configuration, use a list: "data_dirs": ["po", "data"].
Earlier directories take precedence over later ones, followed by Weblate's
bundled rules and gettext's system rules. The directories are passed through
GETTEXTDATADIRS. Configure them explicitly even when using Meson; Weblate
does not read data_dirs from meson.build or inherit an administrator's
GETTEXTDATADIRS environment variable.
Rule directories and files must stay inside the repository and must not be
symbolic links. A locating rule's target must name an existing .its file
in the same directory. DTDs, entity declarations, and external rule references
are not supported. Weblate validates project-local rules before extraction and
reports invalid rules as add-on errors. Changes, additions, or deletions in the
configured its/ directories trigger extraction even when source files
have not changed.
参见
挤压 Git 提交¶
- 附加组件 ID:
weblate.git.squash- 配置:
squash挤压提交
可用选项:¶ all所有提交成一个
language每种语言
file每个文件
author每位作者
author-language每个作者和语言
append_trailers在挤压的提交说明附上尾注
尾注行是类似于 RFC 822 电子邮件标头的行,位于提交说明的其他自由格式部分的末尾,例如 “Co-authored-by: …”。
commit_message提交说明
将使用此提交说明来代替挤压提交的组合提交说明。
- 触发器:
在推送变更之前挤压 Git 提交。
提示
为了避免不必要的冲突,建议配置通过 webhooks 或 API 自动接收上游更改,见 更新仓库。
在推送变更之前,可以通过以下任一模式挤压 Git 提交:
所有提交成一个
每种语言
每个文件
每位作者
每个作者和语言
原始提交说明保留,但其作者信息丢失,除非选择 每位作者,或者定制提交说明来包括它。
可以选择使用自定义提交说明覆盖原始提交说明。
可以选择从原始提交说明中删除尾注(像 Co-authored-by: … 这样的提交行),并附在挤压的提交说明的末尾。这也会为每位译者产生合适的 Co-authored-by: 记录。
自定义 JSON 输出¶
在 5.12 版本发生变更: 添加了 分隔符后避免空格 选项。
Removed in version 5.13: 被 文件格式参数 替代。
将仓库重置为上游状态¶
Added in version 5.17.
每晚丢弃 Weblate 仓库中的所有更改。
格式化 Java 属性文件¶
- 附加组件 ID:
weblate.properties.sort- 配置:
case_sensitive对键排序启用大小写
- 触发器:
对 Java 属性文件进行格式化和排序。
将换行符合并到 Unix 换行符。
Unicode 转义序列的大写格式(如果存在)。
去除空白行和注释。
按键对字符串进行排序。
删除重复的字符串。
过时评论删除¶
设置删除评论的时间。
这可以用于删除可能已经过时的陈旧评论。小心使用,因为评论变旧并不意味着它们已经失去了重要性。
过时建议删除¶
- 附加组件 ID:
weblate.removal.suggestions- 配置:
age保留天数
votes投票阈值
移除阈值。留空表示不论票数多少都删除建议。关闭投票时该项无效果。
- 触发器:
设置删除建议的时间。
可与建议投票(参见 同行评审)结合使用,用于删除在给定时间内未获得足够赞成票的建议。
更新 RESX 文件¶
更新所有翻译文件以匹配上游单语言译文模版文件。未使用的字符串将被删除,新字符串将复制源字符串添加。
提示
如果只想删除陈旧的翻译键,那么使用 清理翻译文件。
Slack Webhooks¶
Added in version 5.12.
- 附加组件 ID:
weblate.webhook.slack- 配置:
- 触发器:
根据所选事件向 Slack 频道发送通知。
警告
通知内容可能会显示 HTML 标签。这是一个已知问题,很快就会解决;请查看 https://github.com/WeblateOrg/weblate/issues/15056。
提示
要获取 webhook URL,请按照 Slack Incoming Webhooks 文档 中概述的步骤操作
Webhook¶
Added in version 5.11.
在 5.15 版本发生变更: 现在验证 secret 长度是符合规范。
- 附加组件 ID:
weblate.webhook.webhook- 配置:
- 触发器:
按照 Standard Webhooks 规范,根据所选事件向外部服务发送通知。
请求载荷遵循 Weblate Messaging 方案。action 字段使用 已选中更改事件 中所列的操作名。OpenAPI 描述也可在 /api/docs/ 找到。示例请求正文:
{
"change_id": 99,
"action": "Translation changed",
"timestamp": "2019-08-24T14:15:22Z",
"target": "Nazdar svete!",
"old": "Nazdar!",
"source": "Hello, world",
"url": "/translate/project-slug/component-slug/cs/?checksum=46add148a53cab6f",
"author": "author-username",
"user": "user-username",
"project": "project-slug",
"component": "component-slug",
"translation": "cs"
}
带有类别的示例请求正文:
{
"change_id": 8910,
"action": "Component renamed",
"timestamp": "2025-06-11T07:15:09Z",
"target": ["new-name"],
"old": ["component-slug"],
"url": "/projects/project-slug/parent-category/child-category/sub-category/component-slug/",
"user": "testuser",
"project": "project-slug",
"component": "component-slug",
"category": [
"sub-category",
"child-category",
"parent-category"
]
}
示例请求标头:
{
"webhook-id": "7f1c5477f6275a69af7b83236c20cb1a",
"webhook-timestamp": "1748505623.044281",
"webhook-signature": "v1,Ceo5qEr07ixe2NLpvHk3FH9bwy/WavXrAFQ/9tdO6mc="
}
webhook-signature 是一个空格分隔的 HMAC 签名列表,使用 secret 字符串、请求负载、webhook-timestamp 和 webhook-id 生成。这确保了 webhook 请求的真实性和完整性。
提供的 secret 是 base64 编码的字符串,大小在 24 字节 (192 比特)和 64 字节 (512 比特)之间。前缀可以是 whsec_ 便于识别。
要验证请求,您可以使用 standardwebhooks 库中的 Webhook.verify 方法或“Standard Webhooks 规范”的实现。
The 自动翻译 mode Add as approved translation creates approved strings when reviews are enabled for the target language. If the project settings or a language workflow override disable reviews, it creates translated strings instead. The configured mode is preserved, including for project-wide and site-wide add-ons whose targets have different review settings. Configuring this mode requires the usual add-on management permission; it does not require the configuring user to be a reviewer.
The 部件发现 add-on stops with an error if the repository scan exceeds 100,000 paths or matching translation files would require more than 1,000,000 path-to-mask comparisons. The comparison limit is checked using the number of repository paths multiplied by the number of file masks. These fixed limits bound resource consumption when repository content determines the masks. When either limit is exceeded, discovery does not create or remove components.
The Webhook and
Slack Webhooks add-ons request uncompressed responses and
reject responses with a Content-Encoding other than identity before
reading their bodies. They limit each response body to 1 MiB and response
headers to 64 KiB, including duplicate headers and separators.
If a response is encoded or either fixed limit is exceeded, Weblate closes the
response and records an add-on error without storing the response body or headers.
The remote service might already have accepted the notification even when
Weblate records this error.
淘汰的附加组件¶
在注释中添加贡献信息¶
Removed in version 2026.10: 被 在注释中添加贡献信息 替换。
Existing installations of weblate.gettext.authors are migrated to the
gettext value of the po_contributor_comments file format parameter for
each affected PO component. This includes components covered by category-,
project-, and site-wide installations. New components default to disabled unless
their file format parameters are copied from another component.
Remove weblate.addons.gettext.GettextAuthorComments from custom
WEBLATE_ADDONS lists and weblate.gettext.authors entries from
DEFAULT_ADDONS. Configure 在注释中添加贡献信息 instead.
自定义 XML 输出¶
Added in version 4.15.
Removed in version 5.13: 被 文件格式参数 替代。
自定义 YAML 输出¶
Removed in version 5.13: 被 文件格式参数 替代。
常见附加组件参数¶
机器翻译引擎¶
|
Alibaba |
|
Amazon 翻译 |
|
Anthropic |
|
Apertium APy |
|
Azure AI 翻译工具 |
|
Azure OpenAI |
|
百度 |
|
CyrTranslit |
|
DeepL |
|
Glosbe |
|
Google Cloud 翻译高级版 |
|
Google Cloud 翻译基础版 |
|
LTEngine |
|
LibreTranslate |
|
Mistral |
|
ModernMT |
|
MyMemory |
|
网易见外 |
|
Ollama |
|
OpenAI |
|
SAP 翻译中心 |
|
Systran |
|
Weblate |
|
Weblate 翻译记忆库 |
|
Yandex |
|
Yandex v2 |
|
有道智云 |
|
eTranslation |
|
tmserver |
文件格式¶
|
含 Apple 扩展的 XLIFF 1.2 |
|
应用商店元数据文件 |
|
ARB 文件 |
|
Android 字符串资源 |
|
AsciiDoc 文件 |
|
Advanced SubStation Alpha(ASS)字幕文件 |
|
Haiku catkeys |
|
Compose 多平台资源 |
|
CSV 文件 |
|
多值 CSV 文件 |
|
简单 CSV 文件 |
|
DokuWiki 文本文件 |
|
DTD 文件 |
|
Flat XML 文件 |
|
Fluent 文件 |
|
Format.JS JSON 文件 |
|
go-i18n v1 JSON 文件 |
|
go-i18n v2 JSON 文件 |
|
go-i18n v1 TOML 文件 |
|
gotext JSON 文件 |
|
GWT 属性 |
|
HTML 文件 |
|
i18next JSON 文件 v3 |
|
i18next JSON 文件 v4 |
|
IDML 文件 |
|
INI 文件 |
|
Inno Setup INI 文件 |
|
Joomla 语言文件 |
|
JSON 文件 |
|
JSON 嵌套结构文件 |
|
Laravel PHP 字符串 |
|
Markdown 文件 |
|
MDX 文件 |
|
MediaWiki 文本文件 |
|
@draggable/i18n lang 文件 |
|
Mobile Kotlin 资源 |
|
Nextcloud JSON 文件 |
|
OpenDocument 文件 |
|
PHP 字符串 |
|
gettext PO 文件 |
|
gettext PO 文件(单语种) |
|
带 gettext 扩展的 XLIFF 1.2 |
|
Java 属性 |
|
RC 文件 |
|
RESJSON 文件 |
|
ResourceDictionary 文件 |
|
.NET 资源文件 |
|
Ruby YAML 文件 |
|
SubRip 字幕文件 |
|
SubStation Alpha(SSA)字幕文件 |
|
iOS 字符串 |
|
Stringsdict 文件 |
|
MicroDVD 字幕文件 |
|
TermBase eXchange 文件 |
|
TOML 文件 |
|
Qt Linguist 翻译文件(版本号2) |
|
Qt Linguist 翻译文件 (版本号1) |
|
纯文本文件 |
|
WebExtension JSON 文件 |
|
WixLocalization 文件 |
|
XLIFF 1.2 翻译文件 |
|
XLIFF 2.0 翻译文件 |
|
Excel Open XML |
|
XWiki 完整页面 |
|
XWiki Java 属性 |
|
XWiki 页面属性 |
|
YAML 文件 |
更改触发事件¶
|
翻译内容事件 |
|
所有更改事件 |
|
已选中更改事件 |
已选中更改事件¶
The following change actions can appear in notification payloads. Fedora Messaging uses the identifier column in message topics, while webhook payloads use the name column in the action field.
ID |
标识符 |
名称 |
说明 |
|---|---|---|---|
|
|
资源已更新 |
已将翻译文件和其仓库进行同步。 |
|
|
完成了翻译 |
单个编辑后一种翻译语言翻译完毕。自动翻译、上传和批量编辑不会触发此事件。 |
|
|
修改了译文 |
用户编辑了现有译文。 |
|
|
添加了评论 |
添加了一则评论到一条字符串。 |
|
|
添加了建议 |
添加了一则翻译建议。 |
|
|
添加了译文 |
一名用户翻译了一条之前未翻译的字符串。 |
|
|
自动翻译 |
自动翻译添加或更改了一则译文。此事件会触发,而不是“翻译已添加”或“翻译已更改”事件。 |
|
|
接受了建议 |
一个翻译建议被接受为译文。 |
|
|
还原了译文 |
译文恢复到先前的值。 |
|
|
上传了译文 |
翻译文件上传添加或更改了一则译文。此事件会触发,而不是“翻译已添加”或“翻译已更改”事件。 |
|
|
添加了源字符串 |
添加了未包含在仓库或上传更新中的源字符串。 |
|
|
锁定了部件 |
一个部件被锁定,无法进行翻译。 |
|
|
解锁了部件 |
一个部件已解锁,可以进行翻译。 |
|
|
已提交更改 |
提交了待处理的部件更改。 |
|
|
已推送更改 |
向上游推送了仓库更改。 |
|
|
已重置仓库 |
一个仓库被重置为其上游状态。 |
|
|
已合并仓库 |
合并了上游仓库更改。 |
|
|
已变基仓库 |
仓库更改已变基到上游。 |
|
|
仓库合并失败 |
合并上游仓库更改失败。 |
|
|
变基仓库失败 |
变基仓库更改失败。 |
|
|
解析失败 |
Weblate 无法解析翻译文件。 |
|
|
删除了翻译 |
删除了一种翻译语言。 |
|
|
删除了建议 |
删除了一则翻译建议。 |
|
|
替换了翻译 |
搜索并替换操作更改了一个翻译。此事件会触发,而不是“翻译已更改”事件。 |
|
|
仓库推送失败 |
未能将仓库更改推送至上游。 |
|
|
在清理中删除了建议 |
在清理中删除了一则过时的翻译建议。 |
|
|
改变了源字符串 |
在 Weblate 中编辑了一条源字符串。 |
|
|
已添加字符串 |
在 Weblate 中添加了一条新字符串。 |
|
|
批量更改了状态 |
批量更改了一条或多条字符串的翻译状态。 |
|
|
更改了可见性 |
更改了项目或部件可见性。 |
|
|
添加了用户 |
一用户获得了访问许可。 |
|
|
删除了用户 |
移除了一名用户的权限。 |
|
|
核准了译文 |
审核期间批准了一条字符串。 |
|
|
标记为需要编辑 |
一则翻译被标记为需要编辑。 |
|
|
删除了部件 |
删除了一个翻译部件。 |
|
|
删除了项目 |
删除了一个翻译项目。 |
|
|
重命名了项目 |
重命名了一个翻译项目。 |
|
|
重命名了部件 |
重命名了一个翻译部件。 |
|
|
移动了部件 |
在项目内移动了一个部件。 |
|
|
有新贡献者加入 |
用户向翻译作了第一个贡献。 |
|
|
发布了公告 |
发布了一则公告。 |
|
|
触发了警报 |
触发了一则部件警报。 |
|
|
添加了语言 |
添加了一种翻译语言。 |
|
|
已请求添加语言 |
一名用户请求了一种新语言。 |
|
|
创建了项目 |
创建了一个翻译项目。 |
|
|
添加了部件 |
创建了一个翻译部件。 |
|
|
邀请了用户 |
邀请了一名用户到一个项目中。 |
|
|
收到了仓库通知 |
Weblate 从一个代码主机收到了一则仓库通知。 |
|
|
上传并替换了翻译文件 |
一个上传文件替换了一个翻译文件。 |
|
|
更改了许可证 |
更改了项目或部件许可信息。 |
|
|
更改了贡献者许可协议 |
更改了贡献者许可协议。 |
|
|
添加了屏幕截图 |
关联了一张屏幕截图和一条字符串。 |
|
|
上传了屏幕截图 |
上传了一张屏幕截图。 |
|
|
更新了仓库中的字符串 |
从仓库同步时更改了一条字符串。 |
|
|
安装了附加组件 |
安装了一个附加组件。 |
|
|
更改了附加组件配置 |
更改了一个附加组件的配置。 |
|
|
卸载了附加组件 |
卸载了一个附加组件。 |
|
|
删除了字符串 |
从一个翻译中删除了一条字符串。 |
|
|
删除了评论 |
移除了一条字符串评论。 |
|
|
评论已解决 |
一条字符串评论被标记为已解决。 |
|
|
解释已更新 |
更新了一条源字符串的解释。 |
|
|
删除了类别 |
删除了一个部件类别。 |
|
|
重新命名了类别 |
重命名了一个部件类别。 |
|
|
移动了类别 |
移动了一个部件类别。 |
|
|
保存字符串失败 |
Weblate 无法保存一条更改的字符串。 |
|
|
在仓库中添加了字符串 |
从仓库同步时发现了一条新字符串。 |
|
|
上传更新了字符串 |
处理一个上传文件时更改了一条字符串。 |
|
|
上传添加了字符串 |
处理一个上传文件时发现了一条新字符串。 |
|
|
通过上传原文更新了译文 |
上传了源文件后同步了一个翻译。 |
|
|
组件翻译已完成 |
单个编辑后一个部件中的所有语言均翻译完毕。自动翻译、上传和批量编辑不会触发此事件。 |
|
|
应用了强制检查 |
强制检查将一个翻译标记为需要编辑。 |
|
|
传播了更改 |
一个翻译编辑被传播至另一个匹配的字符串。 |
|
|
文件已上传 |
一个文件被上传到一个翻译。 |
|
|
额外标记已更新 |
更新了额外的源字符串标记。 |
|
|
字体已上传 |
上传了一个字体。 |
|
|
字体已更改 |
上传的字体发生改变。 |
|
|
字体已移除 |
删除了一个上传的字体。 |
|
|
已强制同步翻译 |
强制将多个翻译文件和仓库进行了同步。 |
|
|
已强制重新扫描翻译 |
强制扫描了多个翻译文件查找更改。 |
|
|
删除了屏幕截图 |
删除了一张屏幕截图。 |
|
|
添加了标签 |
一个标签被添加到了字符串中。 |
|
|
删除了标签 |
从一条字符串中删除了一个标签。 |
|
|
仓库清理 |
清理了仓库工作树。 |
|
|
在上传中添加了源字符串 |
处理一个上传文件时添加了一条源字符串。 |
|
|
在仓库中添加了源字符串 |
从仓库同步时添加了一条源字符串。 |
|
|
已备份项目 |
创建了一个项目备份。 |
|
|
项目已还原 |
一项目已从备份中还原。 |
|
|
已恢复部件 |
从一个备份恢复了一个部件。 |
|
|
撤销了用户编辑 |
撤销了一名用户所做的所有选中的编辑。 |
|
|
项目设置已更改 |
更改了一处项目设置。 |
|
|
部件设置已更改 |
更改了一处部件设置。 |
|
|
更改了用户权限 |
更改了一名用户的访问权限。 |
|
|
创建了工作区 |
创建了工作区。 |
|
|
更改了工作区设置 |
更改了一处工作区设置。 |
|
|
移动了项目 |
一个项目被移进或移出一个工作区。 |
|
|
远程仓库已更新 |
完成了一个远程仓库更新。 |
|
|
远程仓库更新失败 |
更新一个远程仓库失败。 |
|
|
忽略了警报 |
忽略了一则部件警报。 |
|
|
重新打开了警报 |
在上下文更改后重新打开了一则部件警报。 |
定制附加组件列表¶
附加组件列表由 WEBLATE_ADDONS 配置。要添加其他附加组件,只需在这个设置中包含绝对类名称即可。
编写附加组件¶
你也可以编写自己的附加组件,创建一个 weblate.addons.base.BaseAddon 的子类来定义附加组件元数据,然后实现一个回调来执行处理。
参见
从附加组件执行脚本¶
附加组件还可以用于执行外部脚本。这曾经集成在 Weblate 中,但现在必须写一些代码,将脚本包裹在附加组件中。
# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""Example pre commit script."""
from __future__ import annotations
from typing import ClassVar
from django.utils.translation import gettext_lazy
from weblate.addons.events import AddonEvent
from weblate.addons.scripts import BaseScriptAddon
class ExamplePreAddon(BaseScriptAddon):
# Event used to trigger the script
events: ClassVar[set[AddonEvent]] = {
AddonEvent.EVENT_PRE_COMMIT,
}
# Name of the addon, has to be unique
name = "weblate.example.pre"
# Verbose name and long description
verbose = gettext_lazy("Execute script before commit")
description = gettext_lazy("This add-on 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"
安装方法请参见 定制的质量检查、附加组件、自动建议和自动修复。
对于任何给定的部件,当前路径设置为版本控制系统仓库的根目录时,执行脚本。
此外,以下环境变量是可用的:
- WL_VCS¶
使用的版本控制系统。
- WL_REPO¶
上游仓库 URL。
- WL_PATH¶
版本控制系统仓库的绝对路径。
- WL_BRANCH¶
当前部件配置的仓库分支。
- WL_FILEMASK¶
当前部件的文件掩码。
- WL_TEMPLATE¶
单语言翻译模板的文件名(可以为空)。
- WL_NEW_BASE¶
建立新的翻译所使用文件的文件名(可以为空)。
- WL_FILE_FORMAT¶
用于当前部件的文件格式。
- WL_LANGUAGE¶
当前处理的翻译的语言(对于部件级别的钩子不可用)。
- WL_PREVIOUS_HEAD¶
更新后的上个 HEAD (仅在运行更新后钩子后可用)。
- WL_COMPONENT_SLUG¶
部件标识串用于构建 URL。
- WL_PROJECT_SLUG¶
项目标识串用于构建 URL。
- WL_COMPONENT_NAME¶
部件名称。
- WL_PROJECT_NAME¶
项目名称。
- WL_COMPONENT_URL¶
部件 URL。
- WL_ENGAGE_URL¶
项目参与 URL。
参见
更新后仓库处理¶
可用于在 VCS 上游源更改时更新翻译文件。为了实现这个功能,请记住 Weblate 只能看到提交给版本控制系统的文件,所以您需要将更改作为脚本的一部分提交。
例如,使用 Gulp,您可以使用以下代码来实现:
#! /bin/sh
gulp --gulpfile gulp-i18n-extract.js
git commit -m 'Update source strings' src/languages/en.lang.json
翻译的预提交处理¶
在将翻译提交到仓库之前,使用 commit 脚本自动更改翻译。
它作为组成当前翻译文件名的单一参数而通过。
附加组件活动记录¶
附加组件活动记录保留附加组件执行的踪迹且可用来了解附加组件的活动。
每条记录会显示处理状态为待处理、成功、失败还是已跳过。已跳过的记录会包含附加组件未运行的原因,例如组件不兼容、无相关更改或尚未到达设定的运行计划时间。显示为成功的记录仍可能表示该附加组件检查了输入但未发现需要更改的内容。
对于独立处理各个组件的作用域级附加组件,活动日志会为每个组件包含一条单独的记录。
可以在一定时间间隔后清除记录,方法是配置 ADDON_ACTIVITY_LOG_EXPIRY。