
Weblate 是 Copylefted 的自由软件,是一个基于 Web 的持续本地化系统,被 165+ 个国家/地区的 2500+ 个自由项目和公司使用。
安装它,或使用 weblate.org 上的 Hosted Weblate 服务。
支持
Weblate 是一款自由软件,具有可选的专业支持和云托管产品。查看 https://weblate.org/hosting/ 了解更多信息。
文档
可以在源代码的 docs
目录中找到,或在 https://docs.weblate.org/ 在线查看
安装
设置说明:
缺陷
请将功能请求和问题报告给:
许可协议
Copyright © 2012–2021 Michal Čihař michal@cihar.com
本程序是自由软件:您可以在自由软件基金会发布的 GNU 通用公共许可证第三版,或(您选择的)更新版本的条款之下,将其重新发布并且/或者修改。
发布本程序希望它有用,但不作任何担保;甚至没有应用可销售性或适于特定目的的担保。更多细节请参见 GNU 通用公共许可证。
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Weblate 基础知识
项目和组件架构
在 Weblate 中, 翻译组织成为项目和组件。每个项目可以包含几个组件,并且组件包含各个语言的翻译。组件相应于一个翻译文件(例如 GNU gettext 或 Android 字符串资源)。项目帮助您将组件组织为逻辑的组(例如,将一个应用中使用的所有翻译分组)。
默认情况下,每个项目内都有对跨组件传播的公共字符串的翻译。这减轻了重复和多版本翻译的负担。但假如翻译应当有所不同,可以使用 允许同步翻译 通过 组件配置 禁用翻译传播。
参见
注册和用户个人资料
注册
Everybody can browse projects, view translations or suggest translations by default. Only registered users are allowed to actually save changes, and are credited for every translation made.
You can register by following a few simple steps:
Fill out the registration form with your credentials.
使用邮件中收到的链接来激活注册账号。
Optionally adjust your profile to choose which languages you know.
控制面板
When you sign in, you will see an overview of projects and components, as well as their respective translation progression.
2.5 新版功能.
Components of projects you are watching are shown by default, and cross-referenced with your preferred languages.
提示
You can switch to different views using the navigation tabs.

菜单有以下选项:
Projects > Browse all projects in the main menu showing translation status for each project on the Weblate instance.
Selecting a language in the main menu Languages will show translation status of all projects, filtered by one of your primary languages.
Watched translations in the Dashboard will show translation status of only those projects you are watching, filtered by your primary languages.
In addition, the drop-down can also show any number of component lists, sets of project components preconfigured by the Weblate administrator, see 组件列表.
你可以在你的用户个人资料的 首选项 部分配置你的个人控制面板默认视图。
注解
When Weblate is configured for a single project using
SINGLE_PROJECT
in the settings.py
file (see 配置), the dashboard
will not be shown, as the user will be redirected to a single project or component instead.
用户个人资料
The user profile is accessible by clicking your user icon in the top-right of the top menu, then the Settings menu.
The user profile contains your preferences. Name and e-mail address is used in VCS commits, so keep this info accurate.
注解
All language selections only offer currently translated languages.
提示
Request or add other languages you want to translate by clicking the button to make them available too.
语言
界面语言
请选择你想要在用户界面中展示的语言。
翻译语言
Choose which languages you prefer to translate, and they will be offered on the main page of watched projects, so that you have easier access to these all translations in each of those languages.

第二语言
You can define which secondary languages are shown to you as a guide while translating. An example can be seen in the following image, where the Hebrew language is shown as secondarily:

首选项
控制面板默认视图
在 首选项 选项卡,你可以选择默认显示的控制面板视图。如果你选择 组件列表,你必须从 默认组件列表 下拉菜单中选择要显示哪个组件列表。
参见
编辑器链接
A source code link is shown in the web-browser configured in the 组件配置 by default.
提示
By setting the Editor link, you use your local editor to open the VCS source code file of translated strings. You can use 模板标记.
Usually something like editor://open/?file={{filename}}&line={{line}}
is a good option.
参见
You can find more info on registering custom URL protocols for the editor in the Nette documentation.
通知
Subscribe to various notifications from the Notifications tab. Notifications for selected events on watched or administered projects will be sent to you per e-mail.
Some of the notifications are sent only for events in your languages (for example about new strings to translate), while some trigger at component level (for example merge errors). These two groups of notifications are visually separated in the settings.
You can toggle notifications for watched projects and administered projects and it can be further tweaked (or muted) per project and component. Visit the component overview page and select appropriate choice from the Watching menu.
In case Automatically watch projects on contribution is enabled you
will automatically start watching projects upon translating a string. The
default value depends on DEFAULT_AUTO_WATCH
.
注解
You will not receive notifications for your own actions.

账户
The Account tab lets you set up basic account details, connect various services you can use to sign in into Weblate, completely remove your account, or download your user data (see Weblate 用户数据导出).
注解
The list of services depends on your Weblate configuration, but can be made to include popular sites such as GitLab, GitHub, Google, Facebook, or Bitbucket or other OAuth 2.0 providers.

个人资料
本页的所有字段都是选填的,可以随时删除。填写这些字段即表示您同意我们在您的用户个人资料出现的任何地方共享此数据。
Avatar can be shown for each user (depending on ENABLE_AVATARS
).
These images are obtained using https://gravatar.com/.
许可协议
API 访问
你可以在这里获取或者重置你的 API 访问令牌。
审计日志
Audit log keeps track of the actions performed with your account. It logs IP address and browser for every important action with your account. The critical actions also trigger a notification to a primary e-mail address.
参见
使用 Weblate 进行翻译工作
Thank you for interest in translating using Weblate. Projects can either be set up for direct translation, or by way of accepting suggestions made by users without accounts.
Overall, there are two modes of translation:
The project accepts direct translations
The project only accepts suggestions, which are automatically validated once a defined number of votes is reached
有关翻译工作流的更多信息,请见 翻译工作流。
Options for translation project visibility:
Publicly visible and anybody can contribute
仅指定的翻译员群组可见
翻译项目
Translation projects hold related components; resources for the same software, book, or project.

Translation links
Having navigated to a component, a set of links lead to its actual translation. The translation is further divided into individual checks, like Not translated strings or Strings needing action. If the whole project is translated, without error, All strings is still available. Alternatively you can use the search field to find a specific string or term.

建议
注解
Actual permissions might vary depending on your Weblate configuration.
Anonymous users can only (by default) forward suggestions. Doing so is still available to signed-in users, in cases where uncertainty about the translation arises, prompting other translators to review it.
The suggestions are scanned on a daily basis to remove duplicates and suggestions matching the current translation.
变体
Variants are used to group different length variants of the string. The frontend of your project can then use different strings depending on the screen or window size.
标签
Labels are used to categorize strings within a project to further customize the localization workflow (for example to define categories of strings).
Following labels are used by Weblate:
- Automatically translated
Strings was translated using 自动化翻译.
- Source needs review
String marked for review using 源字符串复查.
参见
翻译
On the translation page, the source string and an editing area for its translation are shown. Should the translation be plural, multiple source strings and editing areas are shown, each described and labeled in the amount of plural forms the translated language has.
All special whitespace characters are underlined in red and indicated with grey symbols. More than one subsequent space is also underlined in red to alert the translator to a potential formatting issue.
Various bits of extra info can be shown on this page, most of which coming from the project source code (like context, comments or where the message is being used). Translation fields for any secondary languages translators select in the preferences will be shown (see 第二语言) above the source string.
Below the translation, translators will find suggestion made by others, to be accepted (✓), accepted with changes (✏️), or deleted (🗑).
复数形式
Words changing form to account of their numeric designation are called plurals. Each language has its own definition of plurals. English, for example, supports one. In the singular definition of for example “car”, implicitly one car is referenced, in the plural definition, “cars” two or more cars are referenced (or the concept of cars as a noun). Languages like for example Czech or Arabic have more plurals and also their rules for plurals are different.
Weblate has full support for each of these forms, in each respective language (by translating every plural separately). The number of fields and how it is in turn used in the translated application or project depends on the configured plural formula. Weblate shows the basic info, and the Language Plural Rules by the Unicode Consortium is a more detailed description.
参见

键盘快捷键
在 2.18 版更改: The keyboard shortcuts have been revamped in 2.18 to less likely collide with browser or system defaults.
以下键盘快捷键可以在翻译中使用:
键盘快捷键 |
描述 |
---|---|
Alt+Home |
导航到当前搜索中的第一个翻译。 |
Alt+End |
导航到当前搜索中的最后一个翻译。 |
Alt+PageUp 或 Ctrl ↑ 或 Alt ↑ 或 Cmd ↑ |
导航到当前搜索中的前一处翻译。 |
Alt+PageDown 或 Ctrl+↓ 或 Alt+↓ 或 Cmd+↓ |
导航到当前搜索中的下一处翻译。 |
Alt+Enter 或 Ctrl+Enter 或 Cmd+Enter |
保存当前翻译。 |
Ctrl+Shift+Enter 或 Cmd+Shift+Enter |
取消标记翻译为“需要编辑”并提交它。 |
Ctrl+E 或 Cmd+E |
Focus translation editor. |
Ctrl+U 或 Cmd+U |
Focus comment editor. |
Ctrl+M 或 Cmd+M |
显示 自动建议 选项卡,请参见 自动建议。 |
Ctrl+1 到 Ctrl+9 或 Cmd+1 到 Cmd+9 |
Copies placeable of given number from source string. |
Ctrl+M+1 到 9 或 Cmd+M+1 到 9 |
Copy the machine translation of given number to current translation. |
Ctrl+I+1 到 9 或 Cmd+I+1 到 9 |
忽略未通过的检查列表中的一个项目。 |
Ctrl+J 或 Cmd+J |
显示 附近字符串 选项卡。 |
Ctrl+S 或 Cmd+S |
定位到搜索框。 |
Ctrl+O 或 Cmd+O |
复制源字符串。 |
Ctrl+Y 或 Cmd+Y |
切换 需要编辑 标记。 |
虚拟键盘
A small visual keyboard row is shown just above the translation field. This can be useful to keep local punctuation in mind (as the row is local to each language), or have characters otherwise hard to type handy.
The shown symbols factor into three categories:
User configured characters defined in the 用户个人资料
Per-language characters provided by Weblate (e.g. quotes or RTL specific characters)
Characters configured using
SPECIAL_CHARS

翻译上下文
This contextual description provides related info about the current string.
- 字符串属性
Things like message ID, context (
msgctxt
) or location in source code.- 截图
Screenshots can be uploaded to Weblate to better inform translators of where and how the string is used, see 字符串的可视化上下文.
- 附近字符串
显示翻译文件中相邻信息。这些信息通常是类似的上下文,并保证翻译的一致性。
- 其它的出现位置
如果一条信息出现在多个地方(例如多个组件),若发现它们不一致,这个选项卡会显示所有的信息(参见 不一致的)。你可以选择使用其中之一。
- 翻译记忆库
查找过去翻译的相似字符串,参见 翻译记忆库。
- 术语表
显示当前信息中使用的项目术语表的术语。
- 近期变更
显示最近通过Weblate更改了此信息的人员列表。
- 项目
Project info like instructions for translators, or a directory or link to the string in the version control system repository the project uses.
If you want direct links, the translation format has to support it.
翻译历史记录
Every change is by default (unless turned off in component settings) saved in the database, and can be reverted. Optionally one can still also revert anything in the underlying version control system.
Translated string length
Weblate can limit the length of a translation in several ways to ensure the translated string is not too long:
The default limitation for translation is ten times longer than the source string. This can be turned off by
LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH
. In case you are hitting this, it might be also caused by a monolingual translation erroneously set up as bilingual one, making Weblate mistaking the translation key for the actual source string. See 双语和单语格式 for more info.Maximal length in characters defined by translation file or flag, see 译文最大长度.
Maximal rendered size in pixels defined by flags, see 最大翻译大小.
自动建议
Based on configuration and your translated language, Weblate provides suggestions from several machine translation tools and 翻译记忆库. All machine translations are available in a single tab of each translation page.
参见
You can find the list of supported tools in 机器翻译.
自动化翻译
You can use automatic translation to bootstrap translation based on external sources. This tool is called Automatic translation accessible in the Tools menu, once you have selected a component and a language:

Two modes of operation are possible:
使用其他 Weblate 组件作为翻译的来源。
Using selected machine translation services with translations above a certain quality threshold.
您还可以选择要自动翻译的字符串。
警告
Be mindful that this will overwrite existing translations if employed with wide filters such as All strings.
Useful in several situations like consolidating translation between different components (for example the application and its website) or when bootstrapping a translation for a new component using existing translations (translation memory).
The automatically translated strings are labelled by Automatically translated.
参见
频次限制
To avoid abuse of the interface, rate limiting is applied to several operations like searching, sending contact forms or translating. If affected by it, you are blocked for a certain period until you can perform the operation again.
Default limits and fine-tuning is described in the administrative manual, see 频次限制.
搜索并替换
Change terminology effectively or perform bulk fixing of the strings using Search and replace in the Tools menu.
提示
Don’t worry about messing up the strings. This is a two-step process showing a preview of edited strings before the actual change is confirmed.
批量编辑
Bulk editing allows performing one operation on number of strings. You define strings by searching for them and set up something to be done for matching ones. The following operations are supported:
Changing string state (for example to approve all unreviewed strings).
调整翻译标记(请参见 使用标记定制行为)
调整字符串标签(请参见 字符串标签)
提示
This tool is called Bulk edit accessible in the Tools menu of each project, component or translation.
参见
矩阵视图
To compare different languages efficiently you can use the matrix view. It is available on every component page under the Tools menu. First select all languages you want to compare and confirm your selection, after that you can click on any translation to open and edit it quickly.
The matrix view is also a very good starting point to find missing translations in different languages and quickly add them from one view.
禅模式
The Zen editor can be enabled by clicking the Zen button on the top right while translating a component. It simplifies the layout and removes additional UI elements such as Nearby strings or the Glossary.
You can select the Zen editor as your default editor using the 首选项 tab on your 用户个人资料. Here you can also choose between having translations listed Top to bottom or Side by side depending on your personal preference.
Downloading and uploading translations
You can export files from a translation, make changes, and import them again. This allows working offline, and then merging changes back into the existing translation. This works even if it has been changed in the meantime.
注解
Available options might be limited by access control settings.
Downloading translations
From the project or component dashboard, translatable files can be downloaded in the Files menu.
The first option is to download the file in the original format as it is stored in the repository. In this case, any pending changes in the translation are getting committed and the up-to-date file is yield without any conversions.
You can also download the translation converted into one of the widely used localization formats. The converted files will be enriched with data provided in Weblate; such as additional context, comments or flags. Several file formats are available via the Files ↓ Customize download menu:
gettext PO
带有 gettext 扩展的 XLIFF
XLIFF 1.1
TermBase eXchange
翻译记忆库交换
gettext MO (only available when translation is using gettext PO)
CSV
Excel Open XML
JSON(仅对单语翻译可用)
Android 字符串资源(仅对单语翻译可用)
iOS 字符串 (仅对单语翻译可用)
提示
The content available in the converted files differs based on file format features, you can find overview in 翻译类型功能.

Uploading translations
When you have made your changes, use Upload translation in the Files menu.

支持的文件格式
Any file in a supported file format can be uploaded, but it is still recommended to use the same file format as the one used for translation, otherwise some features might not be translated properly.
参见
The uploaded file is merged to update the translation, overwriting existing entries by default (this can be turned off or on in the upload dialog).
导入方式
These are the choices presented when uploading translation files:
- 添加为翻译 (
translate
) Imported translations are added as translations. This is the most common usecase, and the default behavior.
Only translations are used from the uploaded file and no additional content.
- 添加为建议(
suggest
) Imported translations are added as suggestions, do this when you want to have your uploaded strings reviewed.
Only translations are used from the uploaded file and no additional content.
- 添加为需要编辑的翻译(
fuzzy
) Imported translations are added as translations needing edit. This can be useful when you want translations to be used, but also reviewed.
Only translations are used from the uploaded file and no additional content.
- 替换现有翻译文件(
replace
) Existing file is replaced with new content. This can lead to loss of existing translations, use with caution.
- 更新源字符串(
source
) Updates source strings in bilingual translation file. This is similar to what 更新 PO 文件以匹配 POT 文件 (msgmerge) does.
此选项仅支持某些文件格式。
- 添加新字符串 (
add
) Adds new strings to the translation. It skips the one which already exist.
In case you want to both add new strings and update existing translations, upload the file second time with Add as translation.
This option is available only with 管理字符串 turned on.
仅使用上传文件中的原文、译文和键(上下文)。
Conflicts handling
Defines how to deal with uploaded strings which are already translated.
Strings needing edit
There is also an option for how to handle strings needing edit in the imported file. Such strings can be handle in one of the three following ways: “Do not import”, “Import as string needing edit”, or “Import as translated”.
术语表
Each project can include one or more glossaries as a shorthand for storing terminology. Glossary easify maintaining consistency of the translation.
A glossary for each language can be managed on its own, but they are stored together as a single component which helps project admins and multilingual translators to maintain some cross-language consistency as well. Terms from the glossary containing words from the currently translated string are displayed in the sidebar of the translation editor.
Managing glossaries
在 4.5 版更改: Glossaries are now regular translation components and you can use all Weblate features on them — commenting, storing in a remote repository, or adding explanations.
使用任何组件作为术语表,方法是开启 用作一个术语。你可以为一个项目创建多个术语表。
An empty glossary for a given project is automatically created with the project. Glossaries are shared among all components of the same project, and optionally with other projects using 在项目中分享 from the respective glossary component.
术语表组件看起来与 Weblate 中的其他组件一样,只是多了个彩色标签:

你可以浏览所有术语表术语:

或将它们作为任意翻译进行编辑。
术语表术语
Glossary terms are translated the same way regular strings are. You can toggle additional features using the Tools menu for each term.

不可翻译的术语
4.5 新版功能.
Flagging certain glossary term translations read-only
by bulk-editing, typing in the flag, or
by using Tools ↓ Mark as read-only means they can not
be translated. Use this for brand names or other terms that should not be changed in other languages.
Such terms are visually highlighted in the glossary sidebar.
参见
禁止的翻译
4.5 新版功能.
Flagging certain glossary term translations as forbidden
, by bulk-editing,
typing in the flag, or by using Tools ↓ Mark as forbidden translation
means they are not to be used. Use this to clarify translation when some words are
ambiguous or could have unexpected meanings.
参见
专有名词
4.5 新版功能.
Flagging certain glossary terms as terminology
by bulk-editing, typing in the flag,
or by using Tools ↓ Mark as terminology adds entries for them
to all languages in the glossary. Use this for important terms that should
be well thought out, and retain a consistent meaning across all languages.
参见
变体
Variants are a generic way to group strings together. All term variants are listed in the glossary sidebar when translating.
提示
You can use this to add abbreviations or shorter expressions for a term.
参见
检查并修正
质量检查有助于发现常见的翻译错误,确保翻译质量良好。如果出现误报,则可以忽略这些检查。
一旦提交了未通过检查的翻译,会立即向用户显示:

自动修正
除了 质量检查 外,Weblate 还可以自动修复翻译字符串中的一些常见错误。谨慎使用它,不要使其增加翻译错误。
参见
质量检查
Weblate 对字符串进行了广泛的质量检查。以下部分将对它们进行更详细的描述。还有针对特定语言的检查。如果有错误报告,请将缺陷提交。
参见
翻译检查
在每次翻译更改时执行,帮助翻译人员保持高质量的翻译。
BBcode 标记
- 概览
译文中的 BBcode 和原文不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.markup.BBCodeCheck
- 忽略的标记
ignore-bbcode
BBCode 表示简单的标记,例如以粗体或斜体突出显示消息的重要部分。
此检查确保在翻译中也找到它们。
注解
目前检测 BBcode 的方法非常简单,所以此检查可能会产生误报。
连续重复的单词
4.1 新版功能.
- 概览
一行文本中包含同一单词两次:
- 范围
已翻译字符串
- 检查 class
weblate.checks.duplicate.DuplicateCheck
- 忽略的标记
ignore-duplicate
检查翻译中是否有连续重复的单词出现。这通常表示翻译中存在错误。
提示
此检查包括特定语言的规则,以避免误报。如果在您的情况下错误触发,请告诉我们。请参阅 在 Weblate 中汇报问题。
不遵循术语表
4.5 新版功能.
- 概览
翻译未遵循术语表中定义的术语。
- 范围
已翻译字符串
- 检查 class
weblate.checks.glossary.GlossaryCheck
- 启用的标记
check-glossary
- 忽略的标记
ignore-check-glossary
This check has to be turned on using check-glossary
flag (see
使用标记定制行为). Please consider following prior to enabling it:
It does exact string matching, the glossary is expected to contain terms in all variants.
Checking each string against glossary is expensive, it will slow down any operation in Weblate which involves running checks like importing strings or translating.
双空格
- 概览
翻译包含双空格
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.DoubleSpaceCheck
- 忽略的标记
ignore-double-space
检查翻译中是否存在双空格,以避免其他与空格相关的检查出现误报。
当在原文中找到双空格时,检查为假,这意味着双空格是故意的。
格式化字符串
检查字符串中的格式化是否在原文和译文中都得到了复制。在译文中省略格式字符串通常会导致严重的问题,所以字符串中的格式化通常应与原文匹配。
Weblate 支持检查多种语言的格式字符串。仅当适当地标记了字符串时(例如 C 格式为 c-format),才会自动启用该检查。Gettext 会自动添加它,但是对于其他文件格式,或者如果您的 PO 文件不是由 xgettext 生成的,您可能必须手动添加它。
可以按每单位(请参阅 源字符串另外的信息)或在 组件配置 中完成此操作。为每个组件定义它比较简单,但是如果该字符串未解释为格式化字符串,而碰巧使用了格式化字符串语法,则可能导致误报。
提示
如果 Weblate 中不提供特定格式的检查,则可以使用通用 占位符。
除了检查,这也将高亮格式化字符串,方便将它们插入到已翻译字符串:

AngularJS 插值字符串
- 概览
AngularJS 插值字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.angularjs.AngularJSInterpolationCheck
- 启用的标记
angularjs-format
- 忽略的标记
ignore-angularjs-format
- 命名的格式字符串示例
Your balance is {{amount}} {{ currency }}
C 格式
- 概览
C 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.CFormatCheck
- 启用的标记
c-format
- 忽略的标记
ignore-c-format
- 简单的格式字符串样例
There are %d apples
- Position 格式字符串样例
Your balance is %1$d %2$s
C# 格式
- 概览
C# 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.CSharpFormatCheck
- 启用的标记
c-sharp-format
- 忽略的标记
ignore-c-sharp-format
- Position 格式字符串样例
There are {0} apples
ECMAScript 模板文字
- 概览
ECMAScript 模板文字和原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.ESTemplateLiteralsCheck
- 启用的标记
es-format
- 忽略的标记
ignore-es-format
- 插值例子
There are ${number} apples
i18next 插值
4.0 新版功能.
- 概览
i18next 插值和原文不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.I18NextInterpolationCheck
- 启用的标记
i18next-interpolation
- 忽略的标记
ignore-i18next-interpolation
- 插值例子
There are {{number}} apples
- 嵌套例子
There are $t(number) apples
ICU MessageFormat
4.9 新版功能.
- 概览
ICU MessageFormat 字符串语法错误和/或占位符不匹配。
- 范围
已翻译字符串
- 检查 class
weblate.checks.icu.ICUMessageFormatCheck
- 启用的标记
icu-message-format
- 忽略的标记
ignore-icu-message-format
- 插值例子
There {number, plural, one {is one apple} other {are # apples}}.
This check has support for both pure ICU MessageFormat messages as well as ICU with simple
XML tags. You can configure the behavior of this check by using icu-flags:*
, either by
opting into XML support or by disabling certain sub-checks. For example, the following flag
enables XML support while disabling validation of plural sub-messages:
|
Enable support for simple XML tags. By default, XML tags
are parsed loosely. Stray |
|
Enable support for strict XML tags. All |
|
停用在编辑器中突出显示占位符。 |
|
Disable requiring sub-messages to have an |
|
跳过检查子消息选择器是否与原文匹配。 |
|
跳过检查占位符类型是否与原文匹配。 |
|
Skip checking that no placeholders are present that were not present in the source string. |
|
Skip checking that no placeholders are missing that were present in the source string. |
Additionally, when strict-xml
is not enabled but xml
is enabled, you can use the
icu-tag-prefix:PREFIX
flag to require that all XML tags start with a specific string.
For example, the following flag will only allow XML tags to be matched if they start with
<x:
:
This would match <x:link>click here</x:link>
but not <strong>this</strong>
.
Java 格式
- 概览
Java 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.JavaFormatCheck
- 启用的标记
java-format
- 忽略的标记
ignore-java-format
- 简单的格式字符串样例
There are %d apples
- Position 格式字符串样例
Your balance is %1$d %2$s
Java MessageFormat
- 概览
Java MessageFormat 字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.JavaMessageFormatCheck
- Flag to enable uncodintionally
java-messageformat
- 启用自动检测的标记
auto-java-messageformat
enables check only if there is a format string in the source- 忽略的标记
ignore-java-messageformat
- Position 格式字符串样例
There are {0} apples
JavaScript 格式
- 概览
JavaScript 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.JavaScriptFormatCheck
- 启用的标记
javascript-format
- 忽略的标记
ignore-javascript-format
- 简单的格式字符串样例
There are %d apples
Lua 格式
- 概览
Lua 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.LuaFormatCheck
- 启用的标记
lua-format
- 忽略的标记
ignore-lua-format
- 简单的格式字符串样例
There are %d apples
Object Pascal 格式
- 概览
Object Pascal 格式字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.ObjectPascalFormatCheck
- 启用的标记
object-pascal-format
- 忽略的标记
ignore-object-pascal-format
- 简单的格式字符串样例
There are %d apples
百分比占位符
4.0 新版功能.
- 概览
提供的百分比占位符与原文不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.PercentPlaceholdersCheck
- 启用的标记
percent-placeholders
- 忽略的标记
ignore-percent-placeholders
- 简单的格式字符串样例
There are %number% apples
参见
Perl 格式
- 概览
Perl 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.PerlFormatCheck
- 启用的标记
perl-format
- 忽略的标记
ignore-perl-format
- 简单的格式字符串样例
There are %d apples
- Position 格式字符串样例
Your balance is %1$d %2$s
参见
PHP 格式
- 概览
PHP 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.PHPFormatCheck
- 启用的标记
php-format
- 忽略的标记
ignore-php-format
- 简单的格式字符串样例
There are %d apples
- Position 格式字符串样例
Your balance is %1$d %2$s
Python brace 格式
- 概览
Python 大括号格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.PythonBraceFormatCheck
- 启用的标记
python-brace-format
- 忽略的标记
ignore-python-brace-format
- Simple format string
There are {} apples
- 命名的格式字符串示例
Your balance is {amount} {currency}
Python 格式
- 概览
Python 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.PythonFormatCheck
- 启用的标记
python-format
- 忽略的标记
ignore-python-format
- Simple format string
There are %d apples
- 命名的格式字符串示例
Your balance is %(amount)d %(currency)s
Qt 格式
- 概览
Qt 格式字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.qt.QtFormatCheck
- 启用的标记
qt-format
- 忽略的标记
ignore-qt-format
- Position 格式字符串样例
There are %1 apples
Qt 复数格式
- 概览
Qt 复数格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.qt.QtPluralCheck
- 启用的标记
qt-plural-format
- 忽略的标记
ignore-qt-plural-format
- 复数格式字符串样例
There are %Ln apple(s)
参见
Ruby 格式
- 概览
Ruby 格式的字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.ruby.RubyFormatCheck
- 启用的标记
ruby-format
- 忽略的标记
ignore-ruby-format
- 简单的格式字符串样例
There are %d apples
- Position 格式字符串样例
Your balance is %1$f %2$s
- 命名的格式字符串示例
Your balance is %+.2<amount>f %<currency>s
- Named template string
Your balance is %{amount} %{currency}
Scheme 格式
- 概览
Scheme 格式字符串与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.SchemeFormatCheck
- 启用的标记
scheme-format
- 忽略的标记
ignore-scheme-format
- 简单的格式字符串样例
There are ~d apples
Vue I18n 格式化
- 概览
Vue I18n 格式化和原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.format.VueFormattingCheck
- 启用的标记
vue-format
- 忽略的标记
ignore-vue-format
- 已命名格式
There are {count} apples
- Rails i18n 格式化
There are %{count} apples
- 连结的语言环境消息
@:message.dio @:message.the_world!
曾被翻译过
- 概览
这个字符串在过去曾被翻译过
- 范围
所有字符串
- 检查 class
weblate.checks.consistency.TranslatedCheck
- 忽略的标记
ignore-translated
Means a string has been translated already. This can happen when the translations have been reverted in VCS or lost otherwise.
不一致的
- 概览
此字符串在此项目中有不止一种翻译,或者在某些组件中未翻译。
- 范围
所有字符串
- 检查 class
weblate.checks.consistency.ConsistencyCheck
- 忽略的标记
ignore-inconsistent
Weblate checks translations of the same string across all translation within a project to help you keep consistent translations.
The check fails on differing translations of one string within a project. This can also lead to inconsistencies in displayed checks. You can find other translations of this string on the Other occurrences tab.
此检查应用于项目中所有开启了 :ref:`component-allow_translation_propagation`的组件。
提示
For performance reasons, the check might not find all inconsistencies, it limits number of matches.
注解
This check also fires in case the string is translated in one component and not in another. It can be used as a quick way to manually handle strings which are not translated in some components just by clicking on the Use this translation button displayed on each line in the Other occurrences tab.
You can use 自动化翻译 addon to automate translating of newly added strings which are already translated in another component.
参见
使用了 Kashida 字母
3.5 新版功能.
- 概览
不应使用装饰性的 kashida 字母
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.KashidaCheck
- 忽略的标记
ignore-kashida
The decorative Kashida letters should not be used in translation. These are also known as Tatweel.
Markdown 链接
3.5 新版功能.
- 概览
Markdown 链接和原文不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.markup.MarkdownLinkCheck
- 启用的标记
md-text
- 忽略的标记
ignore-md-link
Markdown 链接和原文不一致。
Markdown 引用
3.5 新版功能.
- 概览
Markdown 链接引用和原文不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.markup.MarkdownRefLinkCheck
- 启用的标记
md-text
- 忽略的标记
ignore-md-reflink
Markdown 链接引用和原文不一致。
Markdown 语法
3.5 新版功能.
- 概览
Markdown 语法与原文不匹配
- 范围
已翻译字符串
- 检查 class
weblate.checks.markup.MarkdownSyntaxCheck
- 启用的标记
md-text
- 忽略的标记
ignore-md-syntax
Markdown 语法与原文不匹配
译文最大长度
- 概览
译文不应超过给定长度
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.MaxLengthCheck
- 启用的标记
max-length
- 忽略的标记
ignore-max-length
检查翻译的长度是否可匹配可用的空间。这只检查翻译字符的长度。
Unlike the other checks, the flag should be set as a key:value
pair like
max-length:100
.
提示
This check looks at number of chars, what might not be the best metric when using proportional fonts to render the text. The 最大翻译大小 check does check actual rendering of the text.
The replacements:
flag might be also useful to expand placeables before
checking the string.
When xml-text
flag is also used, the length calculation ignores XML tags.
最大翻译大小
- 概览
译文不应超过给定长度
- 范围
已翻译字符串
- 检查 class
weblate.checks.render.MaxSizeCheck
- 启用的标记
max-size
- 忽略的标记
ignore-max-size
3.7 新版功能.
Translation rendered text should not exceed given size. It renders the text with line wrapping and checks if it fits into given boundaries.
This check needs one or two parameters - maximal width and maximal number of lines. In case the number of lines is not provided, one line text is considered.
You can also configure used font by font-*
directives (see
使用标记定制行为), for example following translation flags say that the
text rendered with ubuntu font size 22 should fit into two lines and 500
pixels:
max-size:500:2, font-family:ubuntu, font-size:22
提示
You might want to set font-*
directives in 组件配置 to have the same
font configured for all strings within a component. You can override those
values per string in case you need to customize it per string.
The replacements:
flag might be also useful to expand placeables before
checking the string.
When xml-text
flag is also used, the length calculation ignores XML tags.
不匹配的 \n
- 概览
译文中的 \n 数量和原文不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EscapedNewlineCountingCheck
- 忽略的标记
ignore-escaped-newline
Usually escaped newlines are important for formatting program output.
Check fails if the number of \n
literals in translation do not match the source.
不匹配的冒号
- 概览
原文与译文没有都以冒号结尾
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EndColonCheck
- 忽略的标记
ignore-end-colon
Checks that colons are replicated between both source and translation. The presence of colons is also checked for various languages where they do not belong (Chinese or Japanese).
不匹配的省略号
- 概览
原文与译文没有都以省略号结尾
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EndEllipsisCheck
- 忽略的标记
ignore-end-ellipsis
Checks that trailing ellipses are replicated between both source and translation.
This only checks for real ellipsis (…
) not for three dots (...
).
An ellipsis is usually rendered nicer than three dots in print, and sounds better with text-to-speech.
不匹配的感叹号
- 概览
原文与译文没有都以感叹号结尾
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EndExclamationCheck
- 忽略的标记
ignore-end-exclamation
Checks that exclamations are replicated between both source and translation. The presence of exclamation marks is also checked for various languages where they do not belong (Chinese, Japanese, Korean, Armenian, Limbu, Myanmar or Nko).
不匹配的句号
- 概览
原文与译文没有都以句号结尾
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EndStopCheck
- 忽略的标记
ignore-end-stop
Checks that full stops are replicated between both source and translation. The presence of full stops is checked for various languages where they do not belong (Chinese, Japanese, Devanagari or Urdu).
不匹配的问号
- 概览
原文与译文没有都以问号结尾
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EndQuestionCheck
- 忽略的标记
ignore-end-question
Checks that question marks are replicated between both source and translation. The presence of question marks is also checked for various languages where they do not belong (Armenian, Arabic, Chinese, Korean, Japanese, Ethiopic, Vai or Coptic).
不匹配的分号
- 概览
原文与译文没有都以分号结尾
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EndSemicolonCheck
- 忽略的标记
ignore-end-semicolon
Checks that semicolons at the end of sentences are replicated between both source and translation. This can be useful to keep formatting of entries such as desktop files.
不匹配的换行符
- 概览
译文中的换行数量和原文不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.NewLineCountCheck
- 忽略的标记
ignore-newline-count
Usually newlines are important for formatting program output.
Check fails if the number of \n
literals in translation do not match the source.
缺少复数形式
- 概览
某些复数形式未翻译
- 范围
已翻译字符串
- 检查 class
weblate.checks.consistency.PluralsCheck
- 忽略的标记
ignore-plurals
Checks that all plural forms of a source string have been translated. Specifics on how each plural form is used can be found in the string definition.
Failing to fill in plural forms will in some cases lead to displaying nothing when the plural form is in use.
占位符
3.9 新版功能.
- 概览
翻译缺少一些占位符
- 范围
已翻译字符串
- 检查 class
weblate.checks.placeholders.PlaceholderCheck
- 启用的标记
placeholders
- 忽略的标记
ignore-placeholders
在 4.3 版更改: 你可以使用正则表达式作为占位符。
Translation is missing some placeholders. These are either extracted from the
translation file or defined manually using placeholders
flag, more can be
separated with colon, strings with space can be quoted:
placeholders:$URL$:$TARGET$:"some long text"
In case you have some syntax for placeholders, you can use a regular expression:
placeholders:r"%[^% ]%"
参见
标点间距
3.9 新版功能.
- 概览
双引号前缺少不可换行的空格
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.PunctuationSpacingCheck
- 忽略的标记
ignore-punctuation-spacing
Checks that there is non breakable space before double punctuation sign (exclamation mark, question mark, semicolon and colon). This rule is used only in a few selected languages like French or Breton, where space before double punctuation sign is a typographic rule.
正则表达式
3.9 新版功能.
- 概览
翻译与正则表达式不匹配:
- 范围
已翻译字符串
- 检查 class
weblate.checks.placeholders.RegexCheck
- 启用的标记
regex
- 忽略的标记
ignore-regex
Translation does not match regular expression. The expression is either extracted from the
translation file or defined manually using regex
flag:
regex:^foo|bar$
相同复数
- 概览
一些复数形式采用了相同的翻译
- 范围
已翻译字符串
- 检查 class
weblate.checks.consistency.SamePluralsCheck
- 忽略的标记
ignore-same-plurals
Check that fails if some plural forms are duplicated in the translation. In most languages they have to be different.
换行符开头
- 概览
原文与译文没有都以换行符开头
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.BeginNewlineCheck
- 忽略的标记
ignore-begin-newline
Newlines usually appear in source strings for good reason, omissions or additions can lead to formatting problems when the translated text is put to use.
参见
空格开头
- 概览
原文与译文的开头空格数量不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.BeginSpaceCheck
- 忽略的标记
ignore-begin-space
A space in the beginning of a string is usually used for indentation in the interface and thus important to keep.
换行符结尾
- 概览
原文与译文没有都以换行结符尾
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EndNewlineCheck
- 忽略的标记
ignore-end-newline
Newlines usually appear in source strings for good reason, omissions or additions can lead to formatting problems when the translated text is put to use.
参见
空格结尾
- 概览
原文与译文没有都以空格结尾
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.EndSpaceCheck
- 忽略的标记
ignore-end-space
Checks that trailing spaces are replicated between both source and translation.
Trailing space is usually utilized to space out neighbouring elements, so removing it might break layout.
未更改的翻译
- 概览
原文与译文完全相同
- 范围
已翻译字符串
- 检查 class
weblate.checks.same.SameCheck
- 忽略的标记
ignore-same
Happens if the source and corresponding translation strings is identical, down to at least one of the plural forms. Some strings commonly found across all languages are ignored, and various markup is stripped. This reduces the number of false positives.
This check can help find strings mistakenly untranslated.
The default behavior of this check is to exclude words from the built-in
blacklist from the checking. These are words which are frequently not being
translated. This is useful to avoid false positives on short strings, which
consist only of single word which is same in several languages. This blacklist
can be disabled by adding strict-same
flag to string or component.
不安全的 HTML 网站
3.9 新版功能.
- 概览
这条翻译使用了不安全的 HTML 标记
- 范围
已翻译字符串
- 检查 class
weblate.checks.markup.SafeHTMLCheck
- 启用的标记
safe-html
- 忽略的标记
ignore-safe-html
The translation uses unsafe HTML markup. This check has to be enabled using
safe-html
flag (see 使用标记定制行为). There is also accompanied
autofixer which can automatically sanitize the markup.
提示
When md-text
flag is also used, the Markdown style links are also allowed.
参见
The HTML check is performed by the Bleach library developed by Mozilla.
URL
3.5 新版功能.
- 概览
翻译未包含 URL
- 范围
已翻译字符串
- 检查 class
weblate.checks.markup.URLCheck
- 启用的标记
url
- 忽略的标记
ignore-url
The translation does not contain an URL. This is triggered only in case the unit is marked as containing URL. In that case the translation has to be a valid URL.
XML 标记
- 概览
译文中的 XML 标签和原文不一致
- 范围
已翻译字符串
- 检查 class
weblate.checks.markup.XMLTagsCheck
- 忽略的标记
ignore-xml-tags
This usually means the resulting output will look different. In most cases this is not a desired result from changing the translation, but occasionally it is.
Checks that XML tags are replicated between both source and translation.
注解
This check is disabled by the safe-html
flag as the HTML cleanup done by
it can produce HTML markup which is not valid XML.
XML 语法
2.8 新版功能.
- 概览
该翻译不是有效的 XML
- 范围
已翻译字符串
- 检查 class
weblate.checks.markup.XMLValidityCheck
- 忽略的标记
ignore-xml-invalid
The XML markup is not valid.
注解
This check is disabled by the safe-html
flag as the HTML cleanup done by
it can produce HTML markup which is not valid XML.
零宽空格
- 概览
译文中含有额外的零宽空格字符
- 范围
已翻译字符串
- 检查 class
weblate.checks.chars.ZeroWidthSpaceCheck
- 忽略的标记
ignore-zero-width-space
Zero-width space (<U+200B>) characters are used to break messages within words (word wrapping).
As they are usually inserted by mistake, this check is triggered once they are present in translation. Some programs might have problems when this character is used.
原文检查
原文检查可以帮助开发者提高源字符串的质量。
省略号
- 概览
这个字符串使用三个句点 (…) 代替了省略号 (…)
- 范围
源字符串
- 检查 class
weblate.checks.source.EllipsisCheck
- 忽略的标记
ignore-ellipsis
This fails when the string uses three dots (...
) when it should use an ellipsis character (…
).
Using the Unicode character is in most cases the better approach and looks better rendered, and may sound better with text-to-speech.
ICU MessageFormat 语法
4.9 新版功能.
- 概览
ICU MessageFormat 字符串中的语法错误。
- 范围
源字符串
- 检查 class
weblate.checks.icu.ICUSourceCheck
- 忽略的标记
ignore-icu-message-format-syntax
长期未翻译
4.1 新版功能.
- 概览
这个字符串已经很长时间未被翻译了
- 范围
源字符串
- 检查 class
weblate.checks.source.LongUntranslatedCheck
- 忽略的标记
ignore-long-untranslated
When the string has not been translated for a long time, it can indicate a problem in a source string making it hard to translate.
多项未通过的检查
- 概览
多个语言的翻译都有未通过的检查
- 范围
源字符串
- 检查 class
weblate.checks.source.MultipleFailingCheck
- 忽略的标记
ignore-multiple-failures
Numerous translations of this string have failing quality checks. This is usually an indication that something could be done to improve the source string.
This check failing can quite often be caused by a missing full stop at the end of a sentence, or similar minor issues which translators tend to fix in translation, while it would be better to fix it in the source string.
多个未命名的变量
4.1 新版功能.
- 概览
字符串中有多个未命名的变量,因此译者无法重新排序它们
- 范围
源字符串
- 检查 class
weblate.checks.format.MultipleUnnamedFormatsCheck
- 忽略的标记
ignore-unnamed-format
There are multiple unnamed variables in the string, making it impossible for translators to reorder them.
Consider using named variables instead to allow translators to reorder them.
未复数化
- 概览
这个字符串应该用作复数,但未使用其复数形式
- 范围
源字符串
- 检查 class
weblate.checks.source.OptionalPluralCheck
- 忽略的标记
ignore-optional-plural
The string is used as a plural, but does not use plural forms. In case your translation system supports this, you should use the plural aware variant of it.
For example with Gettext in Python it could be:
from gettext import ngettext
print ngettext("Selected %d file", "Selected %d files", files) % files
搜索
3.9 新版功能.
Advanced queries using boolean operations, parentheses, or field specific lookup can be used to find the strings you want.
When no field is defined, the lookup happens on Source, Translate and Context fields.

Simple search
Any phrase typed into the search box is split into words. Strings containing any
of them are shown. To look for an exact phrase, put “the searchphrase” into
quotes (both single (’) and double (”) quotes will work): "this is a quoted
string"
or 'another quoted string'
.
Fields
source:TEXT
不区分大小写的源字符串搜索。
target:TEXT
Target string case-insensitive search.
context:TEXT
Context string case-insensitive search.
key:TEXT
Key string case-insensitive search.
note:TEXT
不区分大小写的源字符串描述搜索。
location:TEXT
Location string case-insensitive search.
priority:NUMBER
String priority.
added:DATETIME
字符串被添加到 Weblate 时的时间戳。
state:TEXT
State search (
approved
,translated
,needs-editing
,empty
,read-only
), supports Field operators.pending:BOOLEAN
String pending for flushing to VCS.
has:TEXT
Search for string having attributes -
plural
,context
,suggestion
,comment
,check
,dismissed-check
,translation
,variant
,screenshot
,flags
,explanation
,glossary
,note
.is:TEXT
Search for string states (
pending
,translated
,untranslated
).language:TEXT
字符串目标语言。
component:TEXT
Component slug or name case-insensitive search, see 组件标识串 and 组件名称.
project:TEXT
Project slug, see URL slug.
changed_by:TEXT
String was changed by author with given username.
changed:DATETIME
String content was changed on date, supports Field operators.
change_time:DATETIME
String was changed on date, supports Field operators, unlike
changed
this includes event which don’t change content and you can apply custom action filtering usingchange_action
.change_action:TEXT
Filters on change action, useful together with
change_time
. Accepts English name of the change action, either quoted and with spaces or lowercase and spaces replaced by a hyphen. See 搜索变更 for examples.check:TEXT
带有某未通过检查的字符串。
dismissed_check:TEXT
带有已忽略检查的字符串。
comment:TEXT
Search in user comments.
comment_author:TEXT
Filter by comment author.
suggestion:TEXT
Search in suggestions.
suggestion_author:TEXT
Filter by suggestion author.
explanation:TEXT
在解释中搜索。
Boolean operators
You can combine lookups using AND
, OR
, NOT
and parentheses to
form complex queries. For example: state:translated AND (source:hello OR source:bar)
Field operators
You can specify operators, ranges or partial lookups for date or numeric searches:
state:>=translated
State is
translated
or better (approved
).changed:2019
Changed in year 2019.
changed:[2019-03-01 to 2019-04-01]
Changed between two given dates.
Exact operators
You can do an exact match query on different string fields using =
operator. For example, to
search for all source strings exactly matching hello world
, use: source:="hello world"
.
For searching single word expressions, you can skip quotes. For example, to search for all source strings
matching hello
, you can use: source:=hello
.
搜索变更
4.4 新版功能.
Searching for history events can be done using change_action
and
change_time
operators.
For example, searching for strings marked for edit in 2018 can be entered as
change_time:2018 AND change_action:marked-for-edit
or
change_time:2018 AND change_action:"Marked for edit"
.
正则表达式
Anywhere text is accepted you can also specify a regular expression as r"regexp"
.
For example, to search for all source strings which contain any digit between 2
and 5, use source:r"[2-5]"
.
Predefined queries
You can select out of predefined queries on the search page, this allows you to quickly access the most frequent searches:

Ordering the results
There are many options to order the strings according to your needs:

翻译工作流
Using Weblate is a process that brings your users closer to you, by bringing you closer to your translators. It is up to you to decide how many of its features you want to make use of.
以下不是配置 Weblate 的方法的完整列表。您可以将其他工作流基于此处列出的最常见的示例。
翻译访问
:ref:`access control <access-control>`并没有作为一个整体在工作流程中被详细讨论,因它的大多数选项都可以应用于任何工作流。请参考有关如何管理对翻译的访问的相关文档。
在以下各章中,任何用户 都是指有权访问翻译的用户。如果项目是公共项目,则可以是任何经过身份验证的用户,也可以是具有项目 Translate 权限的用户。
翻译状态
每个翻译的字符串可以处于以下状态之一:
- 未翻译
翻译是空的,取决于文件格式,翻译是否可能存储在文件中。
- 需要编辑
翻译需要编辑,这通常是源字符串更改、模糊匹配或翻译者操作的结果。翻译存储在文件中,具体取决于文件格式,它可能被标记为需要编辑(例如,当它在 Gettext 文件中获得一个
fuzzy
标记)。- 等待复查
已翻译,但未进行审核。它作为有效翻译存储在文件中。
- 已批准
翻译已在审核中得到批准。翻译者不能再更改它,只能由审阅者更改。译者只能向其中添加建议。
- 建议
建议仅存储在 Weblate 中,而不存储在翻译文件中。
状态在可能的情况下会呈现在翻译文件中。
提示
In case file format you use does not support storing states, you might want to use 将未更改的译文标记为“需要编辑” addon to flag unchanged strings as needing editing.
直接翻译
这是小型团队最常用的设置,任何人都可以直接翻译。这也是 Weblate 中的默认设置。
任何用户 都可以编辑翻译。
当翻译者不确定更改时,建议是建议更改的可选方法。
设置 |
值 |
备注 |
---|---|---|
启用复查 |
已关闭 |
在项目级别配置。 |
启用建议 |
已开启 |
用户可以在不确定时提出建议,这很有用。 |
建议投票 |
已关闭 |
|
自动接受建议 |
0 |
|
翻译组 |
用户 |
或者通过 per-project access control 进行 翻译。 |
审核者组 |
不可用 |
不曾用过。 |
同行评审
使用此工作流程,任何人都可以添加建议,并且需要其他成员的同意才能被接受为翻译。
任何用户 都可以添加建议。
任何用户 都可以对建议投票。
当给定预定数量的投票时,建议就变成翻译。
设置 |
值 |
备注 |
---|---|---|
启用复查 |
已关闭 |
在项目级别配置。 |
启用建议 |
已开启 |
|
建议投票 |
已关闭 |
|
自动接受建议 |
1 |
您可以设置更高的值,以要求更多的同行评审。 |
翻译组 |
用户 |
或者通过 per-project access control 进行 翻译。 |
审核者组 |
不可用 |
未使用,所有翻译者都审阅。 |
专门的审核者
2.18 新版功能: 从 Weblate 2.18 开始,支持正确的审核工作流。
使用专门的审核者,您有两组用户,一组可以提交翻译,而另一组可以审核它们以确保翻译一致且质量良好。
任何用户 都可以编辑未批准的翻译。
Reviewer 可以批准/否决字符串。
审核者 可以编辑所有翻译(包括批准的翻译)。
建议还可以用于建议更改已批准的字符串。
设置 |
值 |
备注 |
---|---|---|
启用复查 |
已开启 |
在项目级别配置。 |
启用建议 |
已关闭 |
用户可以在不确定时提出建议,这很有用。 |
建议投票 |
已关闭 |
|
自动接受建议 |
0 |
|
翻译组 |
用户 |
或者通过 per-project access control 进行 翻译。 |
审核者组 |
校对 |
或使用 per-project access control 进行 Review. |
打开审核
可以在项目设置的 Workflow 子页面中的项目配置中打开审核(位于 Manage → Settings 菜单中):

注解
根据 Weblate 配置的不同,该设置可能对您不可用。例如,在 Hosted Weblate 上,这不适用于免费托管的项目。
Quality gateway for the source strings
In many cases the original source language strings are coming from developers, because they write the code and provide initial strings. However developers are often not a native speakers in the source language and do not provide desired quality of the source strings. The intermediate translation can help you in addressing this - there is additional quality gateway for the strings between developers and translators and users.
By setting 中间语言文件, this file will be used as source for the strings, but it will be edited to source language to polish it. Once the string is ready in the source language, it will be also available for translators to translate into additional languages.
参见
源字符串复查
通过 启用原文复查,可以对源字符串应用复查过程。启用后,用户可以报告源字符串中的问题。实际过程取决于使用的是双语言还是单语言格式。
对于单语言格式,源字符串复查的行为与 专门的审核者 相似——一旦源字符串汇报了情况,就会被标记为 Needs editing 。
双语格式不允许直接编辑源字符串(通常都是直接从源代码中提取源字符串)。在这种情况下, Source needs review 标签会被附加到翻译者报告的字符串上。您应该复查此类字符串,然后编辑原文或删除标签。
常见问题
配置
如何创建自动化工作流?
Weblate 可以为您半自动处理所有翻译工作。如果授予它对仓库的推送访问权限,则翻译可以在没有交互的情况下进行,除非发生某些合并冲突。
如何通过 SSH 访问仓库?
设置 SSH 密钥的信息请参阅 Accessing repositories 。
如何修复翻译中的合并冲突?
在翻译文件在 Weblate 和上游仓库同时更改时,合并冲突不时发生。通常可以通过在对翻译文件进行更改前(例如在运行 msgmerge 前)合并仓库来避免发生这个情况。只要告诉 Weblate 执行挂起所有的翻译(可以在 Manage 菜单中的 Repository maintenance 中去做),并合并仓库即可(如果自动推送没有打开的话)。
如果你已经遇到了合并冲突,那么在您的机器上本地解决所有冲突的最简单方法是将 Weblate 添加为远程仓库,将它合并到上游,并修复任何冲突。一旦将更改推送回去,Weblate 就将能够使用合并的版本而无需任何其它特殊动作。
注解
取决于你的设置,访问 Weblate 代码库可能需要身份验证。使用 Weblate 中内建的 Git 导出器 时,你需使用用户名和 API 密钥进行身份验证。
# Commit all pending changes in Weblate, you can do this in the UI as well:
wlc commit
# Lock the translation in Weblate, again this can be done in the UI as well:
wlc lock
# Add Weblate as remote:
git remote add weblate https://hosted.weblate.org/git/project/component/
# You might need to include credentials in some cases:
git remote add weblate https://username:APIKEY@hosted.weblate.org/git/project/component/
# Update weblate remote:
git remote update weblate
# Merge Weblate changes:
git merge weblate/main
# Resolve conflicts:
edit …
git add …
…
git commit
# Push changes to upstream repository, Weblate will fetch merge from there:
git push
# Open Weblate for translation:
wlc unlock
如果在 Weblate 中使用多个分支,那么可以对所有的分支做相同的事:
# Add and update Weblate remotes
git remote add weblate-one https://hosted.weblate.org/git/project/one/
git remote add weblate-second https://hosted.weblate.org/git/project/second/
git remote update weblate-one weblate-second
# Merge QA_4_7 branch:
git checkout QA_4_7
git merge weblate-one/QA_4_7
... # Resolve conflicts
git commit
# Merge main branch:
git checkout main
git merge weblates-second/main
... # Resolve conflicts
git commit
# Push changes to the upstream repository, Weblate will fetch the merge from there:
git push
在 gettext PO 文件的情况下,有一种方式以半自动方式来合并冲突:
取回并保存 Weblate Git 仓库的本地克隆。还要得到上游 Git 仓库的第二个新的本地克隆(也就是需要上游 Git 仓库的两份复件:完整的复件和工作复件):
# Add remote:
git remote add weblate /path/to/weblate/snapshot/
# Update Weblate remote:
git remote update weblate
# Merge Weblate changes:
git merge weblate/main
# Resolve conflicts in the PO files:
for PO in `find . -name '*.po'` ; do
msgcat --use-first /path/to/weblate/snapshot/$PO\
/path/to/upstream/snapshot/$PO -o $PO.merge
msgmerge --previous --lang=${PO%.po} $PO.merge domain.pot -o $PO
rm $PO.merge
git add $PO
done
git commit
# Push changes to the upstream repository, Weblate will fetch merge from there:
git push
如何同时翻译几个分支?
Weblate 支持在一个 项目配置 内推送翻译更改。对于每个将其打开的 组件配置 (默认行为),所作的更改自动传递给其它组件。即使分支本身已经非常多样化了,也能以这种方式保持同步,并且不能在他们之间简单地合并翻译更改。
一旦从 Weblate 合并了更改,你可能不得不合并这些分支(取决于于您的开发工作流程),并丢弃差异:
git merge -s ours origin/maintenance
参见
如何翻译多平台项目?
Weblate 支持多种文件格式(请参见 支持的文件格式),最简单的方法就是使用每个平台的原生格式。
一旦在一个项目中将所有平台的翻译文件作为组件添加(请参见 添加翻译项目和组件),就可以立刻使用翻译传播特性(默认打开,并且可以在 组件配置 中关闭),来翻译所有平台的字符串了。
参见
如何导出 Weblate 使用的 Git 仓库?
仓库没有什么特殊的,它存在于 DATA_DIR
目录下面,并被命名为 vcs/<project>/<component>/
。如果有 SSH 范文这台机器,那么可以直接使用仓库。
对于匿名访问,您会想要运行 Git 服务器,并让它为外部世界提供仓库服务。
此外,可以在 Weblate 内替代使用 Git 导出器 而使其自动化。
将更改推送回上游的选项是什么?
这在很大程度上取决于您的设置,Weblate 在这方面非常灵活。这里是一些使用 Weblate 的工作流程的例子:
Weblate 自动推送并合并更改(请参见 如何创建自动化工作流?)。
您需要手动告诉 Weblate 去推送(推送需要访问上游仓库)。
一些人将 Weblate git 仓库的更改手动合并到上游仓库中。
一些人重写由 Weblate 生成的历史(例如通过删除合并提交),合并更改,并告诉 Weblate 重置上游仓库中的内容。
当然您可以按您的意愿自由混用所有这些方法。
如何限制 Weblate 仅访问翻译,而不向其暴露源代码?
可以使用 git submodule 将翻译从源代码中分离出来,而仍将它们至于版本控制之下。
用翻译文件创建一个仓库。
将其作为子模块添加到您的代码中:
git submodule add git@example.com:project-translations.git path/to/translations
将 Weblate 连接到这个仓库上,它不再需要访问包含您源代码的仓库。
可以从 Weblate 更新带有翻译的主仓库,通过:
git submodule update --remote path/to/translations
更多细节请咨询 git submodule 文档。
如何检查 Weblate 是否被正确地设置?
Weblate 包括一组配置检查,可以在管理面板中看到,只需按照管理面板中的 Performance report 连接,或直接打开 /manage/performance/
URL 即可。
为什么所有提交都是由 Weblate <noreply@weblate.org> 提交的?
这是默认的提交者的名称,当创建翻译组件时配置。可以在任何时间在管理时将其更改。
(如果下层的版本管理系统 VCS 支持它的话),每个提交的作者仍会被正确地记录为进行翻译的用户。
参见
用法
如何复查其他人的翻译?
在 Weblate 中,基于工作流程有几种复查方式,请参见 翻译工作流。
你可以在 通知 中订阅做出的任何更改,然后通过电子邮件查看其他人的贡献。
在翻译视图底部有个复查工具,可以在那里选择浏览给定时间以来其他人进行的翻译。
参见
如何提供源字符串的反馈?
在翻译下方的上下文选项卡中,可以通过 Comments 选项卡提供源字符串的反馈,或者与其他翻译者讨论。
翻译时如何使用现有的翻译?
得益于共享的翻译记忆库,Weblate 中的所有翻译都可以使用。
你可以将现有翻译记忆库导入 Weblate。
使用导入功能将概要导入作为翻译、建议或需要复查的翻译。这是使用概要或相似的翻译数据库一次性翻译的最好方法。
可以使用您所具有的所有数据库来设置 tmserver。在翻译时多次使用的时候这种方法很好。
另一个选项是在单一 Weblate 实例中翻译所有相关项目,这样同样可以从其它项目中自动地获取翻译。
Weblate 除了更新翻译,还更新翻译文件吗?
Weblate 尝试将翻译文件中的更改限制为最小。对于有些文件格式,很不幸会导致将文件重新格式化。如果想要将文件保持为自己的格式化方式,请为其使用预提交钩子。
参见
语言定义来自何处以及如何添加自己的语言定义?
语言定义的基本组包括在 Weblate 和 Translate-toolkit 中。这覆盖了超过 150 种语言,并且包括了复数形式和文本方向的信息。
您可以在管理界面自由定义自己的语言,只需要提供与之相关的信息。
参见
Weblate 能将模糊字符串中的更改高亮吗?
Weblate 支持这个功能,然而它需要数据来显示差异。
对于 Gettext PO 文件,更新 PO 文件时,必须将参数 --previous
传递给 msgmerge,例如:
msgmerge --previous -U po/cs.po po/phpmyadmin.pot
对于单语言翻译,Weblate 可以通过 ID 找到之前的字符串,因此可以自动显示差异。
当已经更新了模板时,为什么 Weblate 仍然显示旧的字符串?
Weblate 除了允许翻译者翻译之外,不会尝试以任何方式操作翻译文件。因此当模板或源代码更改时,它也同样不会更新翻译文件。您必须简单地手动去做,并将更改推送到仓库,然后 Weblate 会自动拾取更改。
注解
在更新翻译文件之前在 Weblate 中完成更改合并,这通常是个好主意,因为否则的话通常会以一些合并冲突来结束。
例如对于 gettext PO 文件,可以使用 msgmerge 工具来更新翻译文件:
msgmerge -U locale/cs/LC_MESSAGES/django.mo locale/django.pot
在想要进行自动更新的情况下,可以安装插件 更新 PO 文件以匹配 POT 文件 (msgmerge)。
参见
故障排除
请求有时失败,错误信息为“too many open files”(打开文件过多)
有时当您的 Git 仓库增长太多并您有太多仓库时会发生。压缩 Git 仓库会改善这种情况。
这样做的最容易方式是运行:
# Go to DATA_DIR directory
cd data/vcs
# Compress all Git repositories
for d in */* ; do
pushd $d
git gc
popd
done
参见
当访问网站时,“Bad Request (400)”(错误的请求)错误信息
这很可能因为 ALLOWED_HOSTS
配置不当而产生。需要包含在 Weblate 上访问的所有主机名。例如:
ALLOWED_HOSTS = ["weblate.example.com", "weblate", "localhost"]
参见
“There are more files for the single language (en)”(单一语言‘英语’有多个文件)是什么意思?
当源语言有翻译时这会典型发生。Weblate 跟踪源字符串,并为此保留源字符串。相同语言的附加字符串不会被处理。
提示
对于其它语言可能也会得到相似的错误信息。在这种情况下最可能的原因是在 Weblate 中几个文件映射到单语言上。
这可能是由于同时使用了过时的语言代码和新的语言代码(对于日语是 ja
和 jp
),或者包含了特定国家地区的和通用的语言代码(fr
和 fr_FR
)。更多细节请参见 分析语言代码。
功能
Weblate 支持 Git 和 Mercurial 以外的其它 VCS 吗?
Weblate 当前不支持 vcs-git`(扩展支持 :ref:`vcs-github、Gerrit 和 Subversion)和 Mercurial 以外的任何 VCSes,但能够对其它 VCSes 写后端。
还可以在 Git 中使用 Git remote helpers 来访问其它 VCSes。
Weblate 还支持无 VCS 的操作,请参见 本地文件。
注解
为了本地支持其它 VCSes,Weblate 需要使用分布式 VCS,并可能能够调整来与 Git 和 Mercurial 以外的其它任何 VCSes 工作,但必须有人应用这项支持。
参见
Weblate 如何记录翻译者?
Weblate 中所做的每个更改都将以翻译者的名称提交到版本控制系统(VCS)中。这样,每个更改都具有适当的作者身份,您可以使用用于代码的标准版本控制系统(VCS)工具来进行跟踪。
此外,如果翻译文件格式支持,则文件头会更新为包含翻译者的名称。
为什么 Weblate 强制在单一树中显示所有 PO 文件?
Weblate 的设计方式是将每个 PO 文件表示为单个组件。这对翻译人员来说是有好处的,这样他们就知道他们实际上在翻译什么。
在 4.2 版更改: 翻译人员可以将项目的所有组件作为一个整体翻译成一种特定的语言。
Weblate 为什么使用 sr_Latn 或 zh_Hant 这样的语言代码?
这些是由 RFC 5646 定义的语言代码,而不是以前错误使用的修饰符(对于 @latin
变体)或国家地区代码(对于中文),可以更好地表明它们确实是不同的语言。
Weblate 仍然理解遗留的语言代码,并会将它们映射到当前对应的代码上——例如 sr@latin
将被处理为 sr_Latn
或者 zh@CN
处理为 zh_Hans
。
注解
Weblate defaults to POSIX style language codes with underscore, see 语言定义 for more details.
支持的文件格式
Weblate 支持 translate-toolkit 理解的大多数翻译格式,但是每种格式都略有不同,一些未经充分测试的格式可能会出现问题。
注解
为您的应用程序选择文件格式时,最好在您使用的工具包/平台中保留一些支持完善的格式。这样,您的翻译人员可以额外使用他们习惯使用的任何工具,并且更有可能为您的项目作贡献。
双语和单语格式
支持 monolingual 和 bilingual 格式。双语格式在单个文件中存储两种语言文字——原文和译文(典型示例是 GNU gettext、XLIFF 或 苹果 iOS 字符串 字符串)。另一方面,单语格式通过 ID 识别字符串,每个语言文件仅包含那些语言到任何给定语言(典型为 Android 字符串资源)的映射。两种变体都使用某些文件格式,请参见下面的详细说明。
为了正确使用单语文件,Weblate 需要访问一个包含要翻译的字符串及其原文的完整列表的文件——该文件在 Weblate 中被称为 单语言译文模版语言文件,尽管命名上和你的叫法可能会有所不同。
另外,可以利用 中间语言文件 扩展此工作流程,以包括开发人员提供的字符串,但不要在最终的字符串中使用。
自动检测
Weblate 可以自动检测几种常用的文件格式,但是这种检测会损害您的性能,并且会限制特定于给定文件格式的功能(例如,自动添加新翻译)。
翻译类型功能
所有受支持格式的功能:
格式 |
语言能力 1 |
复数 2 |
Descriptions 3 |
上下文 4 |
位置 5 |
标记 8 |
更多状态 6 |
---|---|---|---|---|---|---|---|
双语 |
支持 |
支持 |
支持 |
支持 |
是 9 |
需要编辑 |
|
单一 |
支持 |
支持 |
支持 |
支持 |
是 9 |
需要编辑 |
|
二者 |
支持 |
支持 |
支持 |
支持 |
是 10 |
需要编辑,已同意 |
|
二者 |
不支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
支持 |
不支持 |
支持 |
不支持 |
||
二者 |
支持 |
支持 |
不支持 |
支持 |
是 10 |
需要编辑 |
|
单一 |
支持 |
是 7 |
不支持 |
不支持 |
是 10 |
||
双语 |
不支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
否 11 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
支持 |
不支持 |
不支持 |
是 10 |
||
二者 |
不支持 |
支持 |
支持 |
支持 |
不支持 |
需要编辑 |
|
单一 |
不支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
是 10 |
||
单一 |
不支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
支持 |
支持 |
支持 |
不支持 |
需要编辑 |
|
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
双语 |
不支持 |
支持 |
不支持 |
不支持 |
是 10 |
||
单一 |
不支持 |
不支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
支持 |
支持 |
不支持 |
不支持 |
不支持 |
||
单一 |
no 12 |
支持 |
不支持 |
不支持 |
不支持 |
- 1
请参见 双语和单语格式
- 2
将带有不同数量的字符串正确本地化时复数是必要的。
- 3
Source string descriptions can be used to pass additional info about the string to translate.
- 4
上下文用于区分在不同领域使用的相同字符串(例如 Sun 可以是 “Sunday” 的缩写,也可以是离我们最近的恒星的名字)。
- 5
字符串在源代码中的位置可能有助于熟练的译者弄清楚字符串是如何使用的。
- 6
除”Not translated”(未翻译)和”Translated”(已翻译)之外,文件格式支持的更多状态。
- 7
XML comment placed before the
<string>
element, parsed as a source string description.- 8
请参见 使用标记定制行为
- 9(1,2)
gettext 类型的注释用作标记。
- 10(1,2,3,4,5,6)
这些标记是从所有基于 XML 格式的非标准属性
weblate-flags
中提取的。此外,通过 XLIFF 标准中定义的maxwidth
属性,max-length:N
是支持的,请参阅 指定翻译标记。- 11
只有 Laravel 支持复数,它使用字符串语法来定义它们,请参见 Localization in Laravel。
- 12
Plurals are handled in the syntax of the strings and not exposed as plurals in Weblate.
只读字符串
3.10 新版功能.
Read-only strings from translation files will be included, but
can not be edited in Weblate. This feature is natively supported by few formats
(XLIFF and Android 字符串资源), but can be emulated in others by adding a
read-only
flag, see 使用标记定制行为.
GNU gettext
翻译自由软件用得最广泛的格式。
通过调整文件头或链接到相应的源文件,可以支持存储在文件中的上下文信息。
双语 gettext PO 文件通常如下所示:
#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "Monday"
msgstr "Pondělí"
#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "Tuesday"
msgstr "Úterý"
#: weblate/accounts/avatar.py:163
msgctxt "No known user"
msgid "None"
msgstr "Žádný"
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
空 |
新翻译的译文模版 |
|
文件格式 |
Gettext PO file |
参见
使用 GNU gettext 来翻译软件、使用 Sphinx 翻译文档、Gettext on Wikipedia、 PO Files、 更新“配置文件”中的 ALL_LINGUAS 变量、 自定义 gettext 输出、 更新 LINGUAS 文件、 生成 MO 文件、 更新 PO 文件以匹配 POT 文件 (msgmerge)
单语 gettext
一些项目决定使用 gettext 作为单语格式 —— 它们仅在源代码中编码 ID,然后将字符串翻译成所有语言,包括英语。支持此功能,尽管在将组件导入 Weblate 时必须明确选择此文件格式。
单语言的 gettext PO 文件通常如下所示:
#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-monday"
msgstr "Pondělí"
#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-tuesday"
msgstr "Úterý"
#: weblate/accounts/avatar.py:163
msgid "none-user"
msgstr "Žádný"
基本语言文件将是:
#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-monday"
msgstr "Monday"
#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-tuesday"
msgstr "Tuesday"
#: weblate/accounts/avatar.py:163
msgid "none-user"
msgstr "None"
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
|
文件格式 |
Gettext PO 文件(单语) |
XLIFF
创建基于 XML 的格式来标准化翻译文件,但最终它是该领域中 许多标准 之一。
XML Localization Interchange File Format (XLIFF) 通常用作双语言格式,但 Weblate 也支持其作为单语言格式。
参见
XML Localization Interchange File Format (XLIFF) 规范
翻译状态
在 3.3 版更改: 3.3 版本前的 Weblate 忽略 state
属性。
文件中的 state
属性在 Weblate 中被部分处理并映射为 “Needs edit” (需要编辑)的状态(如果出现目标的话,后面的状态用于将字符串标记为需要编辑: new
、 needs-translation
、 needs-adaptation
、 needs-l10n
)。如果应该省略 state
属性,只要 <target>
元素存在,那么字符串被认为需要翻译。
如果翻译字符串具有 approved="yes"
,那么它还将被导入 Weblate 作为 “Approved”(同意的),任何其它内容被导入作为 “Waiting for review” (等待复核,这与 XLIFF 规范匹配)。
当存储时,Weblate 如无必要不会添加其它属性:
state
属性只在字符串标记为需要编辑的情况下添加。approved
属性只在字符串已经被复查的情况下添加。在其它情况下不添加属性,但在它们出现的情况下更新。
那意味着当使用 XLIFF 格式时,强烈推荐打开 Weblate 复查过程,从而能看到并更改字符串的同意状态。
相似地在导入这样的文件时(在上传表单中),应该选择 Processing of strings needing edit 之下的 Import as translated。
参见
XLIFF 中的空白字符和新行符
在 XML 格式中不区分通常类型或量的空白字符。如果想要保留,必须将 xml:space="preserve"
标记添加到字符串中。
例如:
<trans-unit id="10" approved="yes">
<source xml:space="preserve">hello</source>
<target xml:space="preserve">Hello, world!
</target>
</trans-unit>
指定翻译标记
还可以通过使用 weblate-flags
属性指定附加的翻译标记(请参见 使用标记定制行为)。Weblate 还理解来自 XLIFF 规范的 maxwidth
和 font
属性:
<trans-unit id="10" maxwidth="100" size-unit="pixel" font="ubuntu;22;bold">
<source>Hello %s</source>
</trans-unit>
<trans-unit id="20" maxwidth="100" size-unit="char" weblate-flags="c-format">
<source>Hello %s</source>
</trans-unit>
解析 font
属性用于字体集、尺寸和粗细,上面的示例显示了全部,尽管只需要字符集。字符集中的任何空白字符被转换为下划线,所以 Source Sans Pro
变成 Source_Sans_Pro
,当命名字符集时请记住这些请参见 管理字型)。
字符串键
Weblate 通过 resname
属性(如果有的话)识别 XLIFF 文件中的单元,并会回退到 id
(如果有的话,则与 file
标签一起)。
resname
属性被认为是人类友好的单元识别符,这也使其比 id
更适合 Weblate 显示。在整个 XLIFF 文件中 resname
必须是唯一的。这是 Weblate 的要求,XLIFF 标准没有涉及到这一点——它没有对此属性施加任何唯一性限制。
用于双语言 XLIFF 的典型 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
空 |
新翻译的译文模版 |
|
文件格式 |
XLIFF 翻译文件 |
用于单语言 XLIFF 的典型 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
|
文件格式 |
XLIFF 翻译文件 |
Java 属性
用于翻译的本地 Java 格式。
Java 属性通常用作单语言翻译。
Weblate 支持这个格式的 ISO-8859-1、UTF-8 和 UTF-16 变体。它们所有都支持存储 Unicode 字符,只是编码不同。在 ISO-8859-1 中,使用了 Unicode 转义序列(例如 zkou\u0161ka
),所有其它编码字符直接或者在 UTF-8 中或者在 UTF-16 中。
注解
加载转义序列也在 UTF-8 模式中工作,因此请小心选择正确的编码组,与您应用的需要匹配。
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
Java Properties (ISO-8859-1) |
mi18n 语言文件
4.7 新版功能.
File format used for JavaScript localization by mi18n. Syntactically it matches Java 属性.
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
mi18n 语言文件 |
GWT 属性
用于翻译的本地 GWT 格式。
GWT 属性通常用作单语言翻译。
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
GWT 属性 |
INI 翻译
4.1 新版功能.
用于翻译的 INI 文件格式。
INI 翻译通常用作单语言翻译。
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
INI File |
Inno Setup INI 翻译
4.1 新版功能.
用于翻译的 Inno Setup INI 文件格式。
Inno Setup INI 翻译,通常用作单语言翻译。
注解
唯一需要注意的差异是 INI 翻译 支持 %n
和 %t
占位符用于换行和制表符。
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
Inno Setup INI 文件 |
注解
当前只支持 Unicode 文件(.islu
),当前不支持 ANSI 变体(.isl
)。
Joomla 翻译
2.12 新版功能.
用于翻译的本地 Joomla 格式。
Joomla 翻译通常用作单语言翻译。
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
Joomla 语言文件 |
Qt Linguist .ts
基于 Qt 的应用中使用的翻译格式。
Qt Linguist 文件既用作双语翻译,也用作单语翻译。
用作双语言时典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
空 |
新翻译的译文模版 |
|
文件格式 |
Qt Linguist 翻译文件 |
用作单语言时典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
|
文件格式 |
Qt Linguist 翻译文件 |
参见
Android 字符串资源
用于翻译应用的 Android 特定文件格式。
Android 字符串是单语言的,单语言译文模版语言文件 存储位置不同于其他 res/values/strings.xml
。
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
Android 字符串资源 |
注解
当前不支持 Android 的 string-array 架构。为了解决这个问题,可以将字符串数组分开:
<string-array name="several_strings">
<item>First string</item>
<item>Second string</item>
</string-array>
变为:
<string-array name="several_strings">
<item>@string/several_strings_0</item>
<item>@string/several_strings_1</item>
</string-array>
<string name="several_strings_0">First string</string>
<string name="several_strings_1">Second string</string>
指向 string 元素的 string-array 应存储在不同文件中,并且不为翻译所用。
这个脚本可以帮助预处理现有的 strings.xml 文件和翻译:https://gist.github.com/paour/11291062
苹果 iOS 字符串
翻译应用的苹果特定的文件格式,用于 iOS 和 iPhone/:index:`iPad <pair: iPad; translation>`应用的翻译。
苹果 iOS 字符串通常用作双语翻译。
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
iOS Strings (UTF-8) |
PHP 字符串
PHP翻译通常只包含一种语言,因此建议指定(最常见的)带英语字符串的模板文件。
示例文件:
<?php
$LANG['foo'] = 'bar';
$LANG['foo1'] = 'foo bar';
$LANG['foo2'] = 'foo bar baz';
$LANG['foo3'] = 'foo bar baz bag';
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
|
文件格式 |
PHP 字符串 |
Laravel PHP 字符串
在 4.1 版更改.
Laravel PHP 本地化文件也支持复数:
<?php
return [
'welcome' => 'Welcome to our application',
'apples' => 'There is one apple|There are many apples',
];
JSON 文件
2.0 新版功能.
在 2.16 版更改: 自从 Weblate 2.16 和最早 2.2.4 版本的 translate-toolkit,也支持嵌套结构的 JSON 文件。
在 4.3 版更改: 即使对于在之前发布版本中中断的复杂情况,JSON 文件的结构也适当保留。
JSON 格式主要用于翻译用 JavaScript 实现的应用程序。
Weblate 当前支持 JSON 翻译的几个变体:
简单的键/值文件,由例如 vue-i18n 或 react-intl 使用。
具有嵌套键的文件。
JSON 翻译通常是单语言的,因此推荐指定带有(最经常使用的)英语字符串的翻译模板文件。
示例文件:
{
"Hello, world!\n": "Ahoj světe!\n",
"Orangutan has %d banana.\n": "",
"Try Weblate at https://demo.weblate.org/!\n": "",
"Thank you for using Weblate.": ""
}
也支持嵌套文件(要求请参见上面),这样的文件看起来像:
{
"weblate": {
"hello": "Ahoj světe!\n",
"orangutan": "",
"try": "",
"thanks": ""
}
}
提示
JSON file 和 JSON nested structure file 都可以处理相同类型的文件。翻译时都保留现有的 JSON 架构。
The only difference between them is when adding new strings using Weblate.
The nested structure format parses the newly added key and inserts the new
string into the matching structure. For example app.name
key is inserted as:
{
"app": {
"name": "Weblate"
}
}
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
JSON nested structure file |
参见
JSON i18next 文件
在 2.17 版更改: Since Weblate 2.17 and with translate-toolkit at-least 2.2.5, i18next JSON files with plurals are supported as well.
i18next is an internationalization framework written in and for JavaScript. Weblate supports its localization files with features such as plurals.
i18next translations are monolingual, so it is recommended to specify a base file with (what is most often the) English strings.
注解
Weblate supports the i18next JSON v3 format. The v2 and v1 variants are mostly compatible, with exception of how plurals are handled.
The v4 variant uses different approach for storing plurals and is currently not supported.
示例文件:
{
"hello": "Hello",
"apple": "I have an apple",
"apple_plural": "I have {{count}} apples",
"apple_negative": "I have no apples"
}
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
i18next JSON 文件 |
参见
go-i18n JSON 文件
4.1 新版功能.
go-i18n translations are monolingual, so it is recommended to specify a base file with (what is most often the) English strings.
注解
Weblate supports the go-i18n JSON v1 format, for flat JSON formats please use JSON 文件. The v2 format with hash is currently not supported.
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
go-i18n JSON 文件 |
参见
JSON, go-i18n, 更新目标语言文件, 自定义 JSON 输出, 清理翻译文件,
ARB 文件
4.1 新版功能.
ARB translations are monolingual, so it is recommended to specify a base file with (what is most often the) English strings.
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
ARB 文件 |
WebExtension JSON
2.16 新版功能: This is supported since Weblate 2.16 and with translate-toolkit at-least 2.2.4.
File format used when translating extensions for Mozilla Firefox or Google Chromium.
注解
While this format is called JSON, its specification allows to include comments, which are not part of JSON specification. Weblate currently does not support file with comments.
示例文件:
{
"hello": {
"message": "Ahoj světe!\n",
"description": "Description",
"placeholders": {
"url": {
"content": "$1",
"example": "https://developer.mozilla.org"
}
}
},
"orangutan": {
"message": "",
"description": "Description"
},
"try": {
"message": "",
"description": "Description"
},
"thanks": {
"message": "",
"description": "Description"
}
}
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
WebExtension JSON 文件 |
.XML 资源文件
2.3 新版功能.
A .XML resource (.resx) file employs a monolingual XML file format used in Microsoft .NET applications. It is interchangeable with .resw, when using identical syntax to .resx.
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
.NET 资源文件 |
CSV 文件
2.4 新版功能.
CSV 文件可以包含一个原文和译文的简单列表。Weblate 支持以下文件:
带有标头定义字段(
location
,source
,target
,ID
,fuzzy
,context
,translator_comments
,developer_comments
)的文件。这是推荐的方法,因为它最不容易出错。挑选 CSV file 作为一种文件格式。具有两个字段的文件——原文和译文(按此顺序),选择 简单 CSV 文件 作为文件格式。
无标头文件字段顺序由 translate-toolkit:
location
、source
、target
、ID
、fuzzy
、context
、translator_comments
、developer_comments
所定义。选择 CSV file 作为一种文件格式。Remember to define 单语言译文模版语言文件 when your files are monolingual (see 双语和单语格式).
警告
CSV 格式当前会自动检测 CSV 文件的方言。在某些情况下,自动检测可能会失败,您会得到不同的结果。对于值中包含换行符的 CSV 文件尤其如此。解决方法是建议省略引号字符。
示例文件:
Thank you for using Weblate.,Děkujeme za použití Weblate.
双语 CSV 文件的典型Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
空 |
新翻译的译文模版 |
|
文件格式 |
CSV 文件 |
单语 CSV 文件的典型 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
|
文件格式 |
简单 CSV 文件 |
参见
YAML 文件
2.9 新版功能.
The plain YAML files with string keys and values. Weblate also extract strings from lists or dictionaries.
Example of a YAML file:
weblate:
hello: ""
orangutan": ""
try": ""
thanks": ""
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
YAML 文件 |
参见
Ruby YAML 文件
2.9 新版功能.
Ruby i18n YAML files with language as root node.
Example Ruby i18n YAML file:
cs:
weblate:
hello: ""
orangutan: ""
try: ""
thanks: ""
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
Ruby YAML 文件 |
DTD 文件
2.18 新版功能.
Example DTD file:
<!ENTITY hello "">
<!ENTITY orangutan "">
<!ENTITY try "">
<!ENTITY thanks "">
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
DTD 文件 |
Flat XML 文件
3.9 新版功能.
Example of a flat XML file:
<?xml version='1.0' encoding='UTF-8'?>
<root>
<str key="hello_world">Hello World!</str>
<str key="resource_key">Translated value.</str>
</root>
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
Flat XML 文件 |
参见
Windows RC 文件
在 4.1 版更改: Support for Windows RC files has been rewritten.
注解
Support for this format is currently in beta, feedback from testing is welcome.
Example Windows RC file:
LANGUAGE LANG_CZECH, SUBLANG_DEFAULT
STRINGTABLE
BEGIN
IDS_MSG1 "Hello, world!\n"
IDS_MSG2 "Orangutan has %d banana.\n"
IDS_MSG3 "Try Weblate at http://demo.weblate.org/!\n"
IDS_MSG4 "Thank you for using Weblate."
END
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
|
文件格式 |
RC 文件 |
应用商店元数据文件
3.5 新版功能.
Metadata used for publishing apps in various app stores can be translated. Currently the following tools are compatible:
The metadata consists of several textfiles, which Weblate will present as separate strings to translate.
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
|
文件格式 |
应用商店元数据文件 |
字幕文件
3.7 新版功能.
Weblate 可以翻译各种字幕文件:
SubRip 字幕文件 (
*.srt
)MicroDVD 字幕文件 (
*.sub
)Advanced SubStation Alpha 字幕文件 (
*.ass
)SubStation Alpha 字幕文件 (
*.ssa
)
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
|
文件格式 |
SubRip 字幕文件 |
参见
Excel Open XML
3.2 新版功能.
Excel Open XML (.xlsx) files can be imported and exported.
When uploading XLSX files for translation, be aware that only the active
worksheet is considered, and there must be at least a column called source
(which contains the source string) and a column called target
(which
contains the translation). Additionally there should be the column called context
(which contains the context path of the translation string). If you use the XLSX
download for exporting the translations into an Excel workbook, you already get
a file with the correct file format.
HTML 文件
4.1 新版功能.
注解
Support for this format is currently in beta, feedback from testing is welcome.
The translatable content is extracted from the HTML files and offered for the translation.
参见
文本文件
4.6 新版功能.
注解
Support for this format is currently in beta, feedback from testing is welcome.
The translatable content is extracted from the plain text files and offered for the translation. Each paragraph is translated as a separate string.
这种格式有三种风格:
纯文本文件
DokuWiki 文本文件
MediaWiki 文本文件
OpenDocument Format
4.1 新版功能.
注解
Support for this format is currently in beta, feedback from testing is welcome.
The translatable content is extracted from the OpenDocument files and offered for the translation.
IDML Format
4.1 新版功能.
注解
Support for this format is currently in beta, feedback from testing is welcome.
The translatable content is extracted from the Adobe InDesign Markup Language files and offered for the translation.
TermBase eXchange 格式
4.5 新版功能.
TBX is an XML format for the exchange of terminology data.
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
空 |
新翻译的译文模版 |
空 |
文件格式 |
TermBase eXchange 文件 |
参见
Stringsdict 格式
4.8 新版功能.
注解
Support for this format is currently in beta, feedback from testing is welcome.
XML based format used by Apple which is able to store plural forms of a string.
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
Stringsdict 文件 |
Fluent 格式
4.8 新版功能.
注解
Support for this format is currently in beta, feedback from testing is welcome.
Fluent is a monolingual text format that focuses on asymmetric localization: a simple string in one language can map to a complex multi-variant translation in another language.
典型的 Weblate 组件配置 |
|
---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新翻译的译文模版 |
空 |
文件格式 |
Fluent 文件 |
参见
支持其他格式
Most formats supported by translate-toolkit which support serializing can be easily supported, but they did not (yet) receive any testing. In most cases some thin layer is needed in Weblate to hide differences in behavior of different translate-toolkit storages.
To add support for a new format, the preferred approach is to first implement support for it in the translate-toolkit.
版本控制集成
Weblate 当前支持 vcs-git`(扩展支持 :ref:`vcs-github、Gerrit 和 Subversion)和 Mercurial 为版本控制后端。
Accessing repositories
The VCS repository you want to use has to be accessible to Weblate. With a
publicly available repository you just need to enter the correct URL (for
example https://github.com/WeblateOrg/weblate.git
), but for private
repositories or for push URLs the setup is more complex and requires
authentication.
Accessing repositories from Hosted Weblate
For Hosted Weblate there is a dedicated push user registered on GitHub,
Bitbucket, Codeberg and GitLab (with the username weblate, e-mail
hosted@weblate.org
and, named Weblate push user). You need to
add this user as a collaborator and give it appropriate permission to your
repository (read-only is okay for cloning, write is required for pushing).
Depending on service and your organization settings, this happens immediately,
or requires confirmation on the Weblate side.
The weblate user on GitHub accepts invitations automatically within five minutes. Manual processing might be needed on the other services, so please be patient.
Once the weblate user is added, you can configure
源代码库 and 代码库推送 URL using the SSH protocol (for example
git@github.com:WeblateOrg/weblate.git
).
SSH 仓库
访问私有仓库的最常用方法是基于 SSH。授权公共 Weblate SSH 密钥(请参阅 Weblate SSH 密钥)以这种方式访问上游仓库。
警告
在 Github 上,每个密钥只能用一次,见 GitHub 仓库 和 Accessing repositories from Hosted Weblate。
Weblate 还会在首次连接时存储主机密钥指纹,并且在以后进行更改时将无法连接到主机(请参阅 验证 SSH 主机密钥)。
如果需要调整,请从 Weblate 管理界面进行:

Weblate SSH 密钥
Weblate 公钥对浏览 About 页面的所有用户可见。
管理员可以在管理界面登录页面的连接部分(从 SSH keys)生成或显示 Weblate 当前使用的公共密钥。
注解
相应的私有 SSH 密钥当前无法使用密码,因此请确保已受到良好的保护。
提示
对生成的私有 Weblate SSH 密钥进行备份。
验证 SSH 主机密钥
Weblate 在第一次访问时自动存储SSH主机密钥,并记住它们以备将来使用。
如果要在连接到仓库之前对密钥指纹进行验证,请从管理界面的同一部分 :guilabel: ‘ add host key ‘ 添加你要访问的服务器的 SSH 主机密钥。输入您要访问的主机名(例如 gitlab.com
),然后按 Submit。验证其指纹与您添加的服务器匹配。
The added keys with fingerprints are shown in the confirmation message:

GitHub 仓库
Access via SSH is possible (see SSH 仓库), but in case you need to access more than one repository, you will hit a GitHub limitation on allowed SSH key usage (since each key can be used only once).
In case the 推送分支 is not set, the project is forked and changes pushed through a fork. In case it is set, changes are pushed to the upstream repository and chosen branch.
For smaller deployments, use HTTPS authentication with a personal access token and your GitHub account, see Creating an access token for command-line use.
For bigger setups, it is usually better to create a dedicated user for Weblate, assign it the public SSH key generated in Weblate (see Weblate SSH 密钥) and grant it access to all the repositories you want to translate. This approach is also used for Hosted Weblate, there is dedicated weblate user for that.
Weblate internal URLs
Share one repository setup between different components by referring to
its placement as weblate://project/component
in other(linked) components. This way linked components
use the VCS repository configuration of the main(referenced) component.
警告
Removing main component also removes linked components.
Weblate automatically adjusts the repository URL when creating a component if it finds a component with a matching repository setup. You can override this in the last step of the component configuration.
Reasons to use this:
Saves disk space on the server, the repository is stored just once.
Makes the updates faster, only one repository is updated.
There is just single exported repository with Weblate translations (see Git 导出器).
Some addons can operate on multiple components sharing one repository, for example 压缩(Squash) Git 提交.
HTTPS repositories
To access protected HTTPS repositories, include the username and password in the URL. Don’t worry, Weblate will strip this info when the URL is shown to users (if even allowed to see the repository URL at all).
For example the GitHub URL with authentication added might look like:
https://user:your_access_token@github.com/WeblateOrg/weblate.git
.
注解
如果你的用户名和密码包含特殊字符,需要对URL进行encode编码,例如 https://user%40example.com:%24password%23@bitbucket.org/…
。
使用代理
If you need to access HTTP/HTTPS VCS repositories using a proxy server, configure the VCS to use it.
This can be done using the http_proxy
, https_proxy
, and all_proxy
environment variables, (as described in the cURL documentation)
or by enforcing it in the VCS configuration, for example:
git config --global http.proxy http://user:password@proxy.example.com:80
Git
提示
Weblate 需要 Git 2.12 或更新版本。
参见
See Accessing repositories for info on how to access different kinds of repositories.
Git 强制推送
This behaves exactly like Git itself, the only difference being that it always force pushes. This is intended only in the case of using a separate repository for translations.
警告
Use with caution, as this easily leads to lost commits in your upstream repository.
Customizing Git configuration
Weblate invokes all VCS commands with HOME=$DATA_DIR/home
(see
DATA_DIR
), therefore editing the user configuration needs to be done
in DATA_DIR/home/.git
.
Git remote helpers
You can also use Git remote helpers for additionally supporting other version control systems, but be prepared to debug problems this may lead to.
At this time, helpers for Bazaar and Mercurial are available within separate
repositories on GitHub: git-remote-hg and git-remote-bzr.
Download them manually and put somewhere in your search path
(for example ~/bin
). Make sure you have the corresponding version control
systems installed.
Once you have these installed, such remotes can be used to specify a repository in Weblate.
To clone the gnuhello
project from Launchpad using Bazaar:
bzr::lp:gnuhello
For the hello
repository from selenic.com using Mercurial:
hg::http://selenic.com/repo/hello
警告
The inconvenience of using Git remote helpers is for example with Mercurial, the remote helper sometimes creates a new tip when pushing changes back.
GitHub
2.3 新版功能.
This adds a thin layer atop Git using the GitHub API to allow pushing translation changes as pull requests, instead of pushing directly to the repository.
Git pushes changes directly to a repository, while GitHub creates pull requests. The latter is not needed for merely accessing Git repositories.
Pushing changes to GitHub as pull requests
If not wanting to push translations to a GitHub repository, they can be sent as either one or many pull requests instead.
你需要配置API凭证以使其生效。
GitLab
3.9 新版功能.
This just adds a thin layer atop Git using the GitLab API to allow pushing translation changes as merge requests instead of pushing directly to the repository.
There is no need to use this to access Git repositories, ordinary Git works the same, the only difference is how pushing to a repository is handled. With Git changes are pushed directly to the repository, while GitLab creates merge request.
Pushing changes to GitLab as merge requests
If not wanting to push translations to a GitLab repository, they can be sent as either one or many merge requests instead.
你需要配置API凭证以使其生效。
Pagure
4.3.2 新版功能.
This just adds a thin layer atop Git using the Pagure API to allow pushing translation changes as merge requests instead of pushing directly to the repository.
There is no need to use this to access Git repositories, ordinary Git works the same, the only difference is how pushing to a repository is handled. With Git changes are pushed directly to the repository, while Pagure creates merge request.
将作为合并请求的更改推送到Pagure
If not wanting to push translations to a Pagure repository, they can be sent as either one or many merge requests instead.
你需要配置API凭证以使其生效。
Gerrit
2.2 新版功能.
Adds a thin layer atop Git using the git-review tool to allow pushing translation changes as Gerrit review requests, instead of pushing them directly to the repository.
The Gerrit documentation has the details on the configuration necessary to set up such repositories.
Mercurial
2.1 新版功能.
Mercurial is another VCS you can use directly in Weblate.
注解
It should work with any Mercurial version, but there are sometimes incompatible changes to the command-line interface which breaks Weblate integration.
参见
See Accessing repositories for info on how to access different kinds of repositories.
Subversion
2.8 新版功能.
Weblate uses git-svn to interact with subversion repositories. It is a Perl script that lets subversion be used by a Git client, enabling users to maintain a full clone of the internal repository and commit locally.
注解
Weblate tries to detect Subversion repository layout automatically - it supports both direct URLs for branch or repositories with standard layout (branches/, tags/ and trunk/). More info about this is to be found in the git-svn documentation. If your repository does not have a standard layout and you encounter errors, try including the branch name in the repository URL and leaving branch empty.
在 2.19 版更改: Before this, only repositories using the standard layout were supported.
Subversion credentials
Weblate expects you to have accepted the certificate up-front (and your
credentials if needed). It will look to insert them into the DATA_DIR
directory. Accept the certificate by using svn once with the $HOME
environment variable set to the DATA_DIR
:
# Use DATA_DIR as configured in Weblate settings.py, it is /app/data in the Docker
HOME=${DATA_DIR}/home svn co https://svn.example.com/example
参见
本地文件
Git
提示
Underneath, this uses Git. It requires Git installed and allows you to switch to using Git natively with full history of your translations.
3.8 新版功能.
Weblate can also operate without a remote VCS. The initial translations are imported by uploading them. Later you can replace individual files by file upload, or add translation strings directly from Weblate (currently available only for monolingual translations).
In the background Weblate creates a Git repository for you and all changes are tracked in. In case you later decide to use a VCS to store the translations, you already have a repository within Weblate can base your integration on.
Weblate 的 REST API
2.6 新版功能: 从 Weblate 2.6 开始可以使用 REST API。
API 可以在 /api/
URL上访问,并且它基于 Django REST framework。你可以直接使用或参考 Weblate 客户端。
身份验证和通用参数
公共项目的 API 无需身份验证即可使用,但未经身份验证的请求会受到严格的限制(默认为每天 100 个请求),所以建议使用身份验证。身份验证使用令牌,你可以在你的个人资料中获取该令牌。在 Authorization
标头中使用它:
- ANY /
API 的通用请求行为、标头、状态码和此处的参数也适用于所有端点。
- 查询参数
format – 响应格式(覆盖了 Accept)。可能的值取决于 REST 框架设置,默认支持
json
和api
。后者为 API 提供了 web 浏览器接口。page – Returns given page of paginated results (use next and previous fields in response to automate the navigation).
- 请求标头
Authorization – 验证为 ``Authorization: Token YOUR-TOKEN``的可选令牌
- 响应标头
Content-Type – 这取决于请求的标头 Accept
Allow – 对象允许的 HTTP 方法的列表
- 响应 JSON 对象
detail (string) – 结果的详细描述(对于 200 OK 以外的 HTTP 状态码)
count (int) – 对象列表的总项目计数
next (string) – 对象列表的下一页 URL
previous (string) – 对象列表的上一页 URL
results (array) – 对象列表的结果
url (string) – 使用 API 访问这个资源的 URL
web_url (string) – 使用浏览器访问这个资源的 URL
- 状态码
200 OK – 当请求被正确地处理时
201 Created – when a new object was created successfully
204 No Content – when an object was deleted successfully
400 Bad Request – 当表单参数丢失时
403 Forbidden – 当访问被拒绝时
429 Too Many Requests – 当出现瓶颈时
身份验证令牌
在 4.10 版更改: 在 4.10 版本中引入了项目范围的令牌。
Each user has his personal access token which can be obtained in the user
profile. Newly generated user tokens have the wlu_
prefix.
It is possible to create project scoped tokens for API access to given project
only. These tokens can be identified by the wlp_
prefix.
身份验证的例子
示例请求:
GET /api/ HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
Authorization: Token YOUR-TOKEN
示例响应:
HTTP/1.0 200 OK
Date: Fri, 25 Mar 2016 09:46:12 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, HEAD, OPTIONS
{
"projects":"http://example.com/api/projects/",
"components":"http://example.com/api/components/",
"translations":"http://example.com/api/translations/",
"languages":"http://example.com/api/languages/"
}
CURL 示例:
curl \
-H "Authorization: Token TOKEN" \
https://example.com/api/
传递参数的示例
对于 POST 方法,参数可以指定为表单提交(application/x-www-form-urlencoded)或 JSON (application/json)。
表单请求示例:
POST /api/projects/hello/repository/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Authorization: Token TOKEN
operation=pull
JSON 请求的示例:
POST /api/projects/hello/repository/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json
Authorization: Token TOKEN
Content-Length: 20
{"operation":"pull"}
CURL 示例:
curl \
-d operation=pull \
-H "Authorization: Token TOKEN" \
http://example.com/api/components/hello/weblate/repository/
CURL JSON 示例:
curl \
--data-binary '{"operation":"pull"}' \
-H "Content-Type: application/json" \
-H "Authorization: Token TOKEN" \
http://example.com/api/components/hello/weblate/repository/
API 频次限制
这个 API 请求限制了速率;对于匿名用户默认配置限制为每天 100 个请求,对于身份验证的用户限制为每小时 5000 个请求。
速率限制可以在 settings.py
中调整;如何配置它的更多细节请参见 Throttling in Django REST framework documentation 。
速率限制在后面的标头中报告:
|
要执行的对速率限制进行限制的请求 |
|
保持限制的请求 |
|
直到速率限制窗口重置时的秒数 |
在 4.1 版更改: 添加速率限制状态的标头。
API 入口点
- GET /api/
API 根入口点。
示例请求:
GET /api/ HTTP/1.1 Host: example.com Accept: application/json, text/javascript Authorization: Token YOUR-TOKEN
示例响应:
HTTP/1.0 200 OK Date: Fri, 25 Mar 2016 09:46:12 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, HEAD, OPTIONS { "projects":"http://example.com/api/projects/", "components":"http://example.com/api/components/", "translations":"http://example.com/api/translations/", "languages":"http://example.com/api/languages/" }
用户
4.0 新版功能.
- GET /api/users/
返回用户列表,如果有权限查看管理用户的话。如果没有,那么会只看到自己的具体信息。
参见
用户对象属性记录在
GET /api/users/(str:username)/
。
- POST /api/users/
创建新用户。
- 参数
username (string) – 用户名
full_name (string) – 用户全名
email (string) – 用户电子邮箱
is_superuser (boolean) – 用户是超级用户吗?(可选的)
is_active (boolean) – 用户是活动用户吗?(可选的)
- GET /api/users/(str: username)/
返回用户的信息。
- 参数
username (string) – 用户的用户名
- 响应 JSON 对象
username (string) – 用户的用户名
full_name (string) – 用户的全名
email (string) – 用户的电子邮箱
is_superuser (boolean) – 用户是否是超级用户
is_active (boolean) – 用户是否是活动用户
date_joined (string) – 创建用户的日期
groups (array) – 连接到关联的组;请参见
GET /api/groups/(int:id)/
示例 JSON 数据:
{ "email": "user@example.com", "full_name": "Example User", "username": "exampleusername", "groups": [ "http://example.com/api/groups/2/", "http://example.com/api/groups/3/" ], "is_superuser": true, "is_active": true, "date_joined": "2020-03-29T18:42:42.617681Z", "url": "http://example.com/api/users/exampleusername/", "statistics_url": "http://example.com/api/users/exampleusername/statistics/" }
- PUT /api/users/(str: username)/
更改用户参数。
- 参数
username (string) – 用户的用户名
- 响应 JSON 对象
username (string) – 用户的用户名
full_name (string) – 用户的全名
email (string) – 用户的电子邮箱
is_superuser (boolean) – 用户是否是超级用户
is_active (boolean) – 用户是否是活动用户
date_joined (string) – 创建用户的日期
- PATCH /api/users/(str: username)/
更改用户参数。
- 参数
username (string) – 用户的用户名
- 响应 JSON 对象
username (string) – 用户的用户名
full_name (string) – 用户的全名
email (string) – 用户的电子邮箱
is_superuser (boolean) – 用户是否是超级用户
is_active (boolean) – 用户是否是活动用户
date_joined (string) – 创建用户的日期
- DELETE /api/users/(str: username)/
删除所有的用户信息并将用户标记为不活动用户。
- 参数
username (string) – 用户的用户名
- POST /api/users/(str: username)/groups/
将群组与用户关联。
- 参数
username (string) – 用户的用户名
- 表单参数
string group_id – 唯一的群组 ID
- GET /api/users/(str: username)/statistics/
用户的统计数据列表。
- 参数
username (string) – 用户的用户名
- 响应 JSON 对象
translated (int) – 用户翻译的数量
suggested (int) – 用户提交建议的数量
uploaded (int) – 用户上传的数量
commented (int) – 用户评论的数量
languages (int) – 用户能够翻译的语言数量
- GET /api/users/(str: username)/notifications/
用户的订阅列表。
- 参数
username (string) – 用户的用户名
- POST /api/users/(str: username)/notifications/
将订阅与用户关联。
- 参数
username (string) – 用户的用户名
- 请求 JSON 对象
notification (string) – 注册通知的名称
scope (int) – 可用选项的通知范围
frequency (int) – 通知的频率选项
- GET /api/users/(str: username)/notifications/(int: subscription_id)/
获得与用户关联的订阅。
- 参数
username (string) – 用户的用户名
subscription_id (int) – 已注册通知ID
- PUT /api/users/(str: username)/notifications/(int: subscription_id)/
编辑与用户关联的订阅。
- 参数
username (string) – 用户的用户名
subscription_id (int) – 已注册通知ID
- 请求 JSON 对象
notification (string) – 注册通知的名称
scope (int) – 可用选项的通知范围
frequency (int) – 通知的频率选项
- PATCH /api/users/(str: username)/notifications/(int: subscription_id)/
编辑与用户关联的订阅。
- 参数
username (string) – 用户的用户名
subscription_id (int) – 已注册通知ID
- 请求 JSON 对象
notification (string) – 注册通知的名称
scope (int) – 可用选项的通知范围
frequency (int) – 通知的频率选项
- DELETE /api/users/(str: username)/notifications/(int: subscription_id)/
删除与用户关联的订阅。
- 参数
username (string) – 用户的用户名
subscription_id – 注册通知的名称
subscription_id – int
群组
4.0 新版功能.
- GET /api/groups/
返回群组列表,如果有权限看到管理群组的话,如果没有,那么会只看到用户所在的群组。
参见
群组对象属性记录在
GET /api/groups/(int:id)/
。
- POST /api/groups/
创建新的群组。
- 参数
name (string) – 组名
project_selection (int) – 给定选项的项目选择的群组
language_selection (int) – 给定选项的语言选择的群组
- GET /api/groups/(int: id)/
返回群组的信息。
- 参数
id (int) – 群组的 ID
- 响应 JSON 对象
name (string) – 群组的名称
project_selection (int) – 相应于对象群组的整数
language_selection (int) – 相应于语言群组的整数
roles (array) – 相关联角色的连接;请参见
GET /api/roles/(int:id)/
projects (array) – 相关联项目的连接;请参见
GET /api/projects/(string:project)/
components (array) – 相关联组件的连接;请参见
GET /api/components/(string:project)/(string:component)/
componentlist (array) – 相关联组件列表的连接;请参见
GET /api/component-lists/(str:slug)/
示例 JSON 数据:
{ "name": "Guests", "project_selection": 3, "language_selection": 1, "url": "http://example.com/api/groups/1/", "roles": [ "http://example.com/api/roles/1/", "http://example.com/api/roles/2/" ], "languages": [ "http://example.com/api/languages/en/", "http://example.com/api/languages/cs/", ], "projects": [ "http://example.com/api/projects/demo1/", "http://example.com/api/projects/demo/" ], "componentlist": "http://example.com/api/component-lists/new/", "components": [ "http://example.com/api/components/demo/weblate/" ] }
- PUT /api/groups/(int: id)/
更改群组参数。
- 参数
id (int) – 群组的 ID
- 响应 JSON 对象
name (string) – 群组的名称
project_selection (int) – 相应于对象群组的整数
language_selection (int) – 相应于语言群组的整数
- PATCH /api/groups/(int: id)/
更改群组参数。
- 参数
id (int) – 群组的 ID
- 响应 JSON 对象
name (string) – 群组的名称
project_selection (int) – 相应于对象群组的整数
language_selection (int) – 相应于语言群组的整数
- DELETE /api/groups/(int: id)/
删除群组。
- 参数
id (int) – 群组的 ID
- POST /api/groups/(int: id)/roles/
将角色与群组关联。
- 参数
id (int) – 群组的 ID
- 表单参数
string role_id – 唯一的角色 ID
- POST /api/groups/(int: id)/components/
将组件与群组关联。
- 参数
id (int) – 群组的 ID
- 表单参数
string component_id – 唯一的组件 ID
- DELETE /api/groups/(int: id)/components/(int: component_id)
从群组删除组件。
- 参数
id (int) – 群组的 ID
component_id (int) – 唯一的组件 ID
- POST /api/groups/(int: id)/projects/
将项目与群组关联。
- 参数
id (int) – 群组的 ID
- 表单参数
string project_id – 唯一的项目 ID
- DELETE /api/groups/(int: id)/projects/(int: project_id)
从群组删除项目。
- 参数
id (int) – 群组的 ID
project_id (int) – 唯一的项目 ID
- POST /api/groups/(int: id)/languages/
将语言与群组关联。
- 参数
id (int) – 群组的 ID
- 表单参数
string language_code – 唯一的语言代码
- DELETE /api/groups/(int: id)/languages/(string: language_code)
从群组删除语言。
- 参数
id (int) – 群组的 ID
language_code (string) – 唯一的语言代码
- POST /api/groups/(int: id)/componentlists/
将组件列表与群组关联。
- 参数
id (int) – 群组的 ID
- 表单参数
string component_list_id – 唯一的组件列表 ID
- DELETE /api/groups/(int: id)/componentlists/(int: component_list_id)
从群组删除组件列表。
- 参数
id (int) – 群组的 ID
component_list_id (int) – 唯一的组件列表 ID
角色
- GET /api/roles/
返回与用户关联的所有角色列表。如果用户是超级用户,那么返回所有现有角色的列表。
参见
角色对象属性记录在
GET /api/roles/(int:id)/
。
- POST /api/roles/
创建新角色。
- 参数
name (string) – 角色名称
permissions (array) – 权限代号列表
- GET /api/roles/(int: id)/
返回角色的信息。
- 参数
id (int) – 角色 ID
- 响应 JSON 对象
name (string) – 角色名称
permissions (array) – 权限代号列表
示例 JSON 数据:
{ "name": "Access repository", "permissions": [ "vcs.access", "vcs.view" ], "url": "http://example.com/api/roles/1/", }
- PUT /api/roles/(int: id)/
更改角色参数。
- 参数
id (int) – 角色的ID
- 响应 JSON 对象
name (string) – 角色名称
permissions (array) – 权限代号列表
- PATCH /api/roles/(int: id)/
更改角色参数。
- 参数
id (int) – 角色的ID
- 响应 JSON 对象
name (string) – 角色名称
permissions (array) – 权限代号列表
- DELETE /api/roles/(int: id)/
删除角色。
- 参数
id (int) – 角色的ID
语言
- GET /api/languages/
返回所有语言的列表。
参见
语言对象属性记录在
GET /api/languages/(string:language)/
。
- POST /api/languages/
创建新的语言。
- 参数
code (string) – 语言名称
name (string) – 语言名称
direction (string) – 文字方向
plural (object) – 语言复数形式与数字
- GET /api/languages/(string: language)/
返回语言的信息。
- 参数
language (string) – 语言代码
- 响应 JSON 对象
code (string) – 语言代码
direction (string) – 文字方向
plural (object) – 语言复数信息的对象
aliases (array) – 语言别名的数组
示例 JSON 数据:
{ "code": "en", "direction": "ltr", "name": "English", "plural": { "id": 75, "source": 0, "number": 2, "formula": "n != 1", "type": 1 }, "aliases": [ "english", "en_en", "base", "source", "eng" ], "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/", "statistics_url": "http://example.com/api/languages/en/statistics/" }
- PUT /api/languages/(string: language)/
更改语言参数。
- 参数
language (string) – 语言的代码
- 请求 JSON 对象
name (string) – 语言名称
direction (string) – 文字方向
plural (object) – 语言复数的细节
- PATCH /api/languages/(string: language)/
更改语言参数。
- 参数
language (string) – 语言的代码
- 请求 JSON 对象
name (string) – 语言名称
direction (string) – 文字方向
plural (object) – 语言复数的细节
- DELETE /api/languages/(string: language)/
删除该语言。
- 参数
language (string) – 语言的代码
- GET /api/languages/(string: language)/statistics/
返回语言的统计数据。
- 参数
language (string) – 语言代码
- 响应 JSON 对象
total (int) – 字符串的总数
total_words (int) – 词的总数
last_change (timestamp) – 语言的上一次更改
recent_changes (int) – 更改的总数
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
translated_words (int) – 已翻译词的数量
translated_words_percent (int) – 已翻译词的百分比
translated_chars (int) – 已翻译字符的数量
translated_chars_percent (int) – 已翻译字符的百分比
total_chars (int) – 总字符的数量
fuzzy (int) – 模糊字符串 (标记为需要编辑)的数量
fuzzy_percent (int) – 模糊字符串 (标记为需要编辑)的百分比
failing (int) – 失败字符串的数量
failing – 失败字符串的百分比
项目
- GET /api/projects/
返回所有项目的列表。
参见
项目对象属性记录在
GET /api/projects/(string:project)/
。
- POST /api/projects/
3.9 新版功能.
创建新项目。
- 参数
name (string) – 项目名称
slug (string) – 项目标识串
web (string) – 项目网站
- GET /api/projects/(string: project)/
返回项目的信息。
- 参数
project (string) – 项目 URL 标识串
- 响应 JSON 对象
name (string) – 项目名称
slug (string) – 项目标识串
web (string) – 项目网站
components_list_url (string) – 组件列表的 URL;请参见
GET /api/projects/(string:project)/components/
repository_url (string) – 仓库状态的 URL;请参见
GET /api/projects/(string:project)/repository/
changes_list_url (string) – 更改列表的 URL;请参见
GET /api/projects/(string:project)/repository/
translation_review (boolean) – 启用复查
source_review (boolean) – 启用原文复查
set_language_team (boolean) – 设置 “Language-Team” 文件头
enable_hooks (boolean) – 启用钩子
instructions (string) – 翻译说明
language_aliases (string) – 语言别名
示例 JSON 数据:
{ "name": "Hello", "slug": "hello", "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }
- PATCH /api/projects/(string: project)/
4.3 新版功能.
通过 PATCH 请求来编辑一个项目。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- DELETE /api/projects/(string: project)/
3.9 新版功能.
删除项目。
- 参数
project (string) – 项目 URL 标识串
- GET /api/projects/(string: project)/changes/
返回项目更改的列表。这本质上是一个项目范围的
GET /api/changes/
接受相同的参数。- 参数
project (string) – 项目 URL 标识串
- 响应 JSON 对象
results (array) – 组件对象的矩阵;请参见
GET /api/changes/(int:id)/
- GET /api/projects/(string: project)/repository/
返回版本控制系统(VCS)仓库状态的信息。这个端点只包含项目所有仓库的整体概况。为了得到更多细节,请使用
GET /api/components/(string:project)/(string:component)/repository/
。- 参数
project (string) – 项目 URL 标识串
- 响应 JSON 对象
needs_commit (boolean) – 是否有待定的更改要提交
needs_merge (boolean) – 是否有上游更改要合并
needs_push (boolean) – 是否有本地更改要推送
示例 JSON 数据:
{ "needs_commit": true, "needs_merge": false, "needs_push": true }
- POST /api/projects/(string: project)/repository/
在版本控制系统(VCS)仓库上执行给定的操作。
- 参数
project (string) – 项目 URL 标识串
- 请求 JSON 对象
operation (string) – 要执行的操作: one of
push
,pull
,commit
,reset
,cleanup
,file-sync
- 响应 JSON 对象
result (boolean) – 操作的结果
CURL 示例:
curl \ -d operation=pull \ -H "Authorization: Token TOKEN" \ http://example.com/api/projects/hello/repository/
JSON 请求的示例:
POST /api/projects/hello/repository/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 {"operation":"pull"}
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS {"result":true}
- GET /api/projects/(string: project)/components/
返回给定项目的翻译组件列表。
- 参数
project (string) – 项目 URL 标识串
- 响应 JSON 对象
results (array) – 组件对象的矩阵;请参见
GET /api/components/(string:project)/(string:component)/
- POST /api/projects/(string: project)/components/
3.9 新版功能.
在 4.3 版更改:
zipfile
和docfile
参数现在可被无 VCS 的组件所接受,见 本地文件.在 4.6 版更改: The cloned repositories are now automatically shared within a project using Weblate internal URLs. Use
disable_autoshare
to turn off this.在给定的项目中新建翻译组件。
提示
Use Weblate internal URLs when creating multiple components from a single VCS repository.
注解
多数组件的新建发生在后台。检查新建组件的
task_url
属性,并按照那里的步骤进行。- 参数
project (string) – 项目 URL 标识串
- 表单参数
file zipfile – 上传到 Weblate 用于翻译初始化的 ZIP 文件
file docfile – 要翻译的文档
boolean disable_autoshare – Disables automatic repository sharing via Weblate internal URLs.
- 请求 JSON 对象
object – 组件参数,参见
GET /api/components/(string:project)/(string:component)/
- 响应 JSON 对象
result (object) – 新建组件对象;请参见
GET /api/components/(string:project)/(string:component)/
JSON can not be used when uploading the files using the
zipfile
anddocfile
parameters. The data has to be uploaded as multipart/form-data.CURL表单请求示例:
curl \ --form docfile=@strings.html \ --form name=Weblate \ --form slug=weblate \ --form file_format=html \ --form new_lang=add \ -H "Authorization: Token TOKEN" \ http://example.com/api/projects/hello/components/
CURL JSON 请求的示例:
curl \ --data-binary '{ "branch": "main", "file_format": "po", "filemask": "po/*.po", "name": "Weblate", "slug": "weblate", "repo": "https://github.com/WeblateOrg/hello.git", "template": "", "new_base": "po/hello.pot", "vcs": "git" }' \ -H "Content-Type: application/json" \ -H "Authorization: Token TOKEN" \ http://example.com/api/projects/hello/components/
JSON request to create a new component from Git:
POST /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 { "branch": "main", "file_format": "po", "filemask": "po/*.po", "name": "Weblate", "slug": "weblate", "repo": "https://github.com/WeblateOrg/hello.git", "template": "", "new_base": "po/hello.pot", "vcs": "git" }
JSON request to create a new component from another one:
POST /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 { "file_format": "po", "filemask": "po/*.po", "name": "Weblate", "slug": "weblate", "repo": "weblate://weblate/hello", "template": "", "new_base": "po/hello.pot", "vcs": "git" }
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS { "branch": "main", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }, "repo": "file:///home/nijel/work/weblate-hello", "template": "", "new_base": "", "url": "http://example.com/api/components/hello/weblate/", "vcs": "git", "web_url": "http://example.com/projects/hello/weblate/" }
- GET /api/projects/(string: project)/languages/
对项目内的所有语言返回编页的统计数据。
3.8 新版功能.
- 参数
project (string) – 项目 URL 标识串
- 响应 JSON 对象
results (array) – 翻译统计数据对象的矩阵
language (string) – 语言名称
code (string) – 语言代码
total (int) – 字符串的总数
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
total_words (int) – 词的总数
translated_words (int) – 已翻译词的数量
words_percent (float) – 已翻译词的百分比
- GET /api/projects/(string: project)/statistics/
返回项目的统计数据。
3.8 新版功能.
- 参数
project (string) – 项目 URL 标识串
- 响应 JSON 对象
total (int) – 字符串的总数
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
total_words (int) – 词的总数
translated_words (int) – 已翻译词的数量
words_percent (float) – 已翻译词的百分比
组件
提示
使用:http:post:/api/projects/(string:project)/components/ 创建新组件。
- GET /api/components/
返回翻译组件的列表。
参见
组件对象属性记录在
GET /api/components/(string:project)/(string:component)/
。
- GET /api/components/(string: project)/(string: component)/
返回翻译组件的信息。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
project (object) – 翻译项目;请参见
GET /api/projects/(string:project)/
name (string) – 组件名称
slug (string) – 组件标识串
vcs (string) – 版本控制系统
repo (string) – 源代码库
git_export (string) – 已导出代码库 URL
branch (string) – 仓库分支
push_branch (string) – 推送分支
filemask (string) – 文件掩码
template (string) – 单语言译文模版语言文件
edit_template (string) – 编辑译文模版文件
intermediate (string) – 中间语言文件
new_base (string) – 新翻译的译文模版
file_format (string) – 文件格式
license (string) – 翻译许可证
agreement (string) – 贡献者协议
new_lang (string) – 添加新翻译
language_code_style (string) – 语言代码风格
source_language (object) – 源语言对象;请参见
GET /api/languages/(string:language)/
push (string) – 代码库推送 URL
check_flags (string) – 翻译标记
priority (string) – 优先级
enforced_checks (string) – 强制检查
restricted (string) – 受限制的访问
repoweb (string) – 代码库浏览器
report_source_bugs (string) – 源字符串缺陷报告地址
merge_style (string) – 合并方式
commit_message (string) – 提交、添加、删除、合并以及插件信息
add_message (string) – 提交、添加、删除、合并以及插件信息
delete_message (string) – 提交、添加、删除、合并以及插件信息
merge_message (string) – 提交、添加、删除、合并以及插件信息
addon_message (string) – 提交、添加、删除、合并以及插件信息
allow_translation_propagation (string) – 允许同步翻译
enable_suggestions (string) – 启用建议
suggestion_voting (string) – 建议投票
suggestion_autoaccept (string) – 自动接受建议
push_on_commit (string) – 提交时推送
commit_pending_age (string) – 对变更进行提交的延时时间
auto_lock_error (string) – 出错时锁定
language_regex (string) – 语言筛选
variant_regex (string) – 正则表达式变体
repository_url (string) – 仓库状态的 URL;请参见
GET /api/components/(string:project)/(string:component)/repository/
translations_url (string) – 翻译列表的 URL;请参见
GET /api/components/(string:project)/(string:component)/translations/
lock_url (string) – 锁定状态的 URL;请参见
GET /api/components/(string:project)/(string:component)/lock/
changes_list_url (string) – 更改的列表的 URL;请参见
GET /api/components/(string:project)/(string:component)/changes/
task_url (string) – 后台任务 URL (如果有的话);请参见
GET /api/tasks/(str:uuid)/
示例 JSON 数据:
{ "branch": "main", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }, "source_language": { "code": "en", "direction": "ltr", "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "repo": "file:///home/nijel/work/weblate-hello", "template": "", "new_base": "", "url": "http://example.com/api/components/hello/weblate/", "vcs": "git", "web_url": "http://example.com/projects/hello/weblate/" }
- PATCH /api/components/(string: project)/(string: component)/
通过 PATCH 请求编辑一个组件。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
source_language (string) – 项目源语言代码(可选)
- 请求 JSON 对象
name (string) – 组件名称
slug (string) – 组件的标识串
repo (string) – 版本控制系统(VCS)仓库的URL
CURL 示例:
curl \ --data-binary '{"name": "new name"}' \ -H "Content-Type: application/json" \ -H "Authorization: Token TOKEN" \ PATCH http://example.com/api/projects/hello/components/
JSON 请求的示例:
PATCH /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 { "name": "new name" }
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS { "branch": "main", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "new name", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }, "repo": "file:///home/nijel/work/weblate-hello", "template": "", "new_base": "", "url": "http://example.com/api/components/hello/weblate/", "vcs": "git", "web_url": "http://example.com/projects/hello/weblate/" }
- PUT /api/components/(string: project)/(string: component)/
通过 PUT 请求编辑一个组件。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 请求 JSON 对象
branch (string) – 版本控制系统(VCS)仓库分支
file_format (string) – 翻译的文件格式
filemask (string) – 仓库中翻译的文件掩码
name (string) – 组件名称
slug (string) – 组件的标识串
repo (string) – 版本控制系统(VCS)仓库的URL
template (string) – 但语言翻译的译文模板文件
new_base (string) – 用于添加新翻译的译文模板文件
vcs (string) – 版本控制系统
- DELETE /api/components/(string: project)/(string: component)/
3.9 新版功能.
删除组件。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- GET /api/components/(string: project)/(string: component)/changes/
返回组件更改的列表。这本质是一个组件范围的 :http:get:`/api/changes/`接受相同的参数。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
results (array) – 组件对象的矩阵;请参见
GET /api/changes/(int:id)/
- GET /api/components/(string: project)/(string: component)/file/
4.9 新版功能.
Downloads all available translations associated with the component as an archive file using the requested format.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 查询参数
format (string) – The archive format to use; If not specified, defaults to
zip
; Supported formats:zip
q (string) – 筛选已下载的字符串,见 搜索页面。
- GET /api/components/(string: project)/(string: component)/screenshots/
返回组件屏幕截图的列表。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
results (array) – 组件屏幕截图的矩阵;请参见
GET /api/screenshots/(int:id)/
- GET /api/components/(string: project)/(string: component)/lock/
返回组件锁定状态。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
locked (boolean) – 组件是否因更新而锁定
示例 JSON 数据:
{ "locked": false }
- POST /api/components/(string: project)/(string: component)/lock/
设置组件锁定状态。
响应时间与 :http:get:`/api/components/(string:project)/(string:component)/lock/`相同。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 请求 JSON 对象
lock – 是否锁定的布尔值。
CURL 示例:
curl \ -d lock=true \ -H "Authorization: Token TOKEN" \ http://example.com/api/components/hello/weblate/repository/
JSON 请求的示例:
POST /api/components/hello/weblate/repository/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 {"lock": true}
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS {"locked":true}
- GET /api/components/(string: project)/(string: component)/repository/
返回版本控制系统(VCS)仓库状态的信息。
响应与
GET /api/projects/(string:project)/repository/
的相同。- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
needs_commit (boolean) – 是否有待定的更改要提交
needs_merge (boolean) – 是否有上游更改要合并
needs_push (boolean) – 是否有本地更改要推送
remote_commit (string) – 远程提交信息
status (string) – 由版本控制系统(VCS)报告的 VCS 状态
merge_failure – 描述合并失败的文本,没有的话为空
- POST /api/components/(string: project)/(string: component)/repository/
在版本控制系统(VCS)仓库执行给定的操作。
文档请参见
POST /api/projects/(string:project)/repository/
。- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 请求 JSON 对象
operation (string) – 执行的操作:
push
,pull
,commit
,reset
, ``cleanup``之一
- 响应 JSON 对象
result (boolean) – 操作的结果
CURL 示例:
curl \ -d operation=pull \ -H "Authorization: Token TOKEN" \ http://example.com/api/components/hello/weblate/repository/
JSON 请求的示例:
POST /api/components/hello/weblate/repository/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 {"operation":"pull"}
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS {"result":true}
- GET /api/components/(string: project)/(string: component)/monolingual_base/
为单语言翻译下载译文模板文件。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- GET /api/components/(string: project)/(string: component)/new_template/
为新的翻译下载模板文件。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- GET /api/components/(string: project)/(string: component)/translations/
返回给定组件中翻译对象的列表。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
results (array) – 翻译对象的矩阵;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/
- POST /api/components/(string: project)/(string: component)/translations/
在给定组件中新建新的翻译。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 请求 JSON 对象
language_code (string) – 翻译语言代码;请参见
GET /api/languages/(string:language)/
- 响应 JSON 对象
result (object) – 新建的新翻译对象
CURL 示例:
curl \ -d language_code=cs \ -H "Authorization: Token TOKEN" \ http://example.com/api/projects/hello/components/
JSON 请求的示例:
POST /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 {"language_code": "cs"}
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS { "failing_checks": 0, "failing_checks_percent": 0, "failing_checks_words": 0, "filename": "po/cs.po", "fuzzy": 0, "fuzzy_percent": 0.0, "fuzzy_words": 0, "have_comment": 0, "have_suggestion": 0, "is_template": false, "is_source": false, "language": { "code": "cs", "direction": "ltr", "name": "Czech", "url": "http://example.com/api/languages/cs/", "web_url": "http://example.com/languages/cs/" }, "language_code": "cs", "id": 125, "last_author": null, "last_change": null, "share_url": "http://example.com/engage/hello/cs/", "total": 4, "total_words": 15, "translate_url": "http://example.com/translate/hello/weblate/cs/", "translated": 0, "translated_percent": 0.0, "translated_words": 0, "url": "http://example.com/api/translations/hello/weblate/cs/", "web_url": "http://example.com/projects/hello/weblate/cs/" }
- GET /api/components/(string: project)/(string: component)/statistics/
对组件内所有的翻译返回分页的统计数据。
2.7 新版功能.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
results (array) – 翻译统计数据对象的矩阵;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/statistics/
- GET /api/components/(string: project)/(string: component)/links/
返回与组件相连的项目。
4.5 新版功能.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
projects (array) – 相关的项目,请参见
GET /api/projects/(string:project)/
- POST /api/components/(string: project)/(string: component)/links/
将项目与一个组件相关联。
4.5 新版功能.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 表单参数
string project_slug – 项目标识串
- DELETE /api/components/(string: project)/(string: component)/links/(string: project_slug)/
删除项目与组件的关联性。
4.5 新版功能.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
project_slug (string) – 要移除的项目的地址
翻译
- GET /api/translations/
返回翻译的列表。
- GET /api/translations/(string: project)/(string: component)/(string: language)/
返回翻译的信息。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- 响应 JSON 对象
component (object) – 组件对象;请参见
GET /api/components/(string:project)/(string:component)/
failing_checks (int) – 未通过检查的字符串数目
failing_checks_percent (float) – 未通过检查的字符串比重
failing_checks_words (int) – 带有未通过检查的单词数目
filename (string) – 翻译文件名
fuzzy (int) – 模糊字符串 (标记为需要编辑)的数量
fuzzy_percent (float) – 模糊字符串 (标记为需要编辑)的百分比
fuzzy_words (int) – 模糊 (标记为编辑))字符串中的单词数
have_comment (int) – 带有评论的字符串数量
have_suggestion (int) – 带有建议的字符串数量
is_template (boolean) – 译文是否有单语基础
language (object) – 源语言对象;请参见
GET /api/languages/(string:language)/
language_code (string) – 仓库中使用的语言代码;这可以不同于语言对象中的语言代码
last_author (string) – 最后一位作者的姓名
last_change (timestamp) – 最后更改的时间戳
revision (string) – 文件的修订哈希值
share_url (string) – 用于分享的 URL,指向参与页面
total (int) – 字符串的总数
total_words (int) – 词的总数
translate_url (string) – 翻译的 URL
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
translated_words (int) – 已翻译词的数量
repository_url (string) – 仓库状态的 URL;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/repository/
file_url (string) – 文件对象的 URL;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/file/
changes_list_url (string) – 更改的列表的 URL;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/changes/
units_list_url (string) – 字符串列表的 URL;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/units/
示例 JSON 数据:
{ "component": { "branch": "main", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "new_base": "", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }, "repo": "file:///home/nijel/work/weblate-hello", "slug": "weblate", "template": "", "url": "http://example.com/api/components/hello/weblate/", "vcs": "git", "web_url": "http://example.com/projects/hello/weblate/" }, "failing_checks": 3, "failing_checks_percent": 75.0, "failing_checks_words": 11, "filename": "po/cs.po", "fuzzy": 0, "fuzzy_percent": 0.0, "fuzzy_words": 0, "have_comment": 0, "have_suggestion": 0, "is_template": false, "language": { "code": "cs", "direction": "ltr", "name": "Czech", "url": "http://example.com/api/languages/cs/", "web_url": "http://example.com/languages/cs/" }, "language_code": "cs", "last_author": "Weblate Admin", "last_change": "2016-03-07T10:20:05.499", "revision": "7ddfafe6daaf57fc8654cc852ea6be212b015792", "share_url": "http://example.com/engage/hello/cs/", "total": 4, "total_words": 15, "translate_url": "http://example.com/translate/hello/weblate/cs/", "translated": 4, "translated_percent": 100.0, "translated_words": 15, "url": "http://example.com/api/translations/hello/weblate/cs/", "web_url": "http://example.com/projects/hello/weblate/cs/" }
- DELETE /api/translations/(string: project)/(string: component)/(string: language)/
3.9 新版功能.
删除翻译。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- GET /api/translations/(string: project)/(string: component)/(string: language)/changes/
返回翻译更改的列表。这本质上是一个翻译范围的 :http:get:`/api/changes/`接受相同的参数。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- 响应 JSON 对象
results (array) – 组件对象的矩阵;请参见
GET /api/changes/(int:id)/
- GET /api/translations/(string: project)/(string: component)/(string: language)/units/
返回翻译单元的列表。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
q (string) – 搜索查询字符串 搜索 (可选)
- 响应 JSON 对象
results (array) – 组件对象的矩阵;请参见
GET /api/units/(int:id)/
- POST /api/translations/(string: project)/(string: component)/(string: language)/units/
添加新的单语言单元。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- 请求 JSON 对象
key (string) – 翻译单元的名称
value (array) – 翻译单元值
- POST /api/translations/(string: project)/(string: component)/(string: language)/autotranslate/
触发自动翻译。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- 请求 JSON 对象
mode (string) – 自动翻译模式
filter_type (string) – 自动翻译筛选类型
auto_source (string) – 自动翻译的来源 -
mt
或others
component (string) – 为项目打开对共享翻译记忆库的贡献,以访问其他组件。
engines (array) – 机器翻译引擎
threshold (string) – 匹配分数阈值
- GET /api/translations/(string: project)/(string: component)/(string: language)/file/
下载存储在 VCS 中的当前翻译文件(不带 ``format``参数)或将其转换为另一格式(见 Downloading translations)。
注解
这个 API 端点使用了不同于API其余的逻辑来输出,它在整个文件而不是在数据上操作。接受的``format``参数组不同,没有这个参数会将翻译文件存储在版本控制系统(VCS)中。
- 查询参数
format – 使用的文件格式;如果不指定,则不会进行格式转换;支持的文件格式有:
po
,mo
,xliff
,xliff11
,tbx
,csv
,xlsx
,json
,aresource
,strings
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- POST /api/translations/(string: project)/(string: component)/(string: language)/file/
上传带有翻译的新文件。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- 表单参数
string conflict – 如何处理冲突(
ignore
,replace-translated
orreplace-approved
)file file – 上传文件
string email – 作者邮箱
string author – 作者姓名
string method – 上传方法 (
translate
,approve
,suggest
,fuzzy
,replace
,source
,add
),见 导入方式string fuzzy – 模糊 (标记为需要编辑)的字符串处理(empty,
process
,approve
)
CURL 示例:
curl -X POST \ -F file=@strings.xml \ -H "Authorization: Token TOKEN" \ http://example.com/api/translations/hello/android/cs/file/
- GET /api/translations/(string: project)/(string: component)/(string: language)/repository/
返回版本控制系统(VCS)仓库状态的信息。
响应与 :http:get:`/api/components/(string:project)/(string:component)/repository/`的相同。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- POST /api/translations/(string: project)/(string: component)/(string: language)/repository/
在版本控制系统(VCS)仓库上执行给定的操作。
文档请参见
POST /api/projects/(string:project)/repository/
。- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- 请求 JSON 对象
operation (string) – 执行的操作:
push
,pull
,commit
,reset
, ``cleanup``之一
- 响应 JSON 对象
result (boolean) – 操作的结果
- GET /api/translations/(string: project)/(string: component)/(string: language)/statistics/
返回具体的翻译统计数据。
2.7 新版功能.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – 翻译语言代码
- 响应 JSON 对象
code (string) – 语言代码
failing (int) – 未通过检查的数量
failing_percent (float) – 未通过检查的百分比
fuzzy (int) – 模糊字符串 (标记为需要编辑)的数量
fuzzy_percent (float) – 模糊字符串 (标记为需要编辑)的百分比
total_words (int) – 词的总数
translated_words (int) – 已翻译词的数量
last_author (string) – 最后一位作者的姓名
last_change (timestamp) – 上次更改的日期
name (string) – 语言名称
total (int) – 字符串的总数
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
url (string) – 访问翻译的 URL(参与 URL)
url_translate (string) – 访问翻译的 URL (真实翻译的 URL)
单元
A unit is a single piece of a translation which pairs a source string with a corresponding translated string and also contains some related metadata. The term is derived from the Translate Toolkit and XLIFF.
2.10 新版功能.
- GET /api/units/
返回翻译单元的列表。
参见
单元对象属性记录在
GET /api/units/(int:id)/
。
- GET /api/units/(int: id)/
在 4.3 版更改:
target
和source
现在是矩阵,来适当的处理多个字符串。返回翻译单元的信息。
- 参数
id (int) – 单元 ID
- 响应 JSON 对象
translation (string) – 相关翻译对象的 URL
source (array) – 源字符串
previous_source (string) – 用于模糊匹配的之前的源字符串
target (array) – 目标字符串
id_hash (string) – 单元的唯一识别文字
content_hash (string) – 源字符串的唯一识别文字
location (string) – 源代码中单元的位置
context (string) – 翻译单元的上下文
note (string) – 翻译单元的注解
flags (string) – 翻译单元的标记
state (int) – 单元状态,0——未翻译,10——需要编辑,20——已翻译,30——以通过,100——只读
fuzzy (boolean) – 该单元是模糊的还是标记为需要复查
translated (boolean) – 单元是否被翻译
approved (boolean) – 翻译是否被核准
position (int) – 翻译文件中的单元位置
has_suggestion (boolean) – 单元是否有翻译建议
has_comment (boolean) – 单元是否有评论
has_failing_check (boolean) – 单元是否有未通过检查的翻译
num_words (int) – 原文单词数
priority (int) – 翻译优先级;100为默认值
id (int) – 单元识别问题
explanation (string) – 字符串的解释,可在源单元获得,请参见 源字符串另外的信息
extra_flags (string) – 另外的字符串标记,可在源单元获得,请参见 使用标记定制行为
web_url (string) – 单元可以被编辑的 URL
souce_unit (string) – 源单元链接;请参见
GET /api/units/(int:id)/
- PATCH /api/units/(int: id)/
4.3 新版功能.
对翻译单元执行部分更新。
- PUT /api/units/(int: id)/
4.3 新版功能.
对翻译单元执行完整翻译。
- DELETE /api/units/(int: id)/
4.3 新版功能.
删除一个翻译单元。
- 参数
id (int) – 单元 ID
变更
2.10 新版功能.
- GET /api/changes/
在 4.1 版更改: 更改的筛选在 4.1 版本引入。
返回翻译更改的列表。
参见
更改对象属性记录在
GET /api/changes/(int:id)/
。- 查询参数
user (string) – 筛选用户的用户名
action (int) – 筛选的动作,可以多次使用
timestamp_after (timestamp) – ISO 8601 格式的时间戳,列出此时间之后的更改
timestamp_before (timestamp) – ISO 8601 格式的时间戳,列出此时间之前的更改
- GET /api/changes/(int: id)/
返回有关翻译更改的信息。
- 参数
id (int) – 更改的ID
- 响应 JSON 对象
unit (string) – 相关单元对象的 URL
translation (string) – 相关翻译对象的 URL
component (string) – 相关组件对象的 URL
user (string) – 相关用户对象的 URL
author (string) – 相关作者对象的 URL
timestamp (timestamp) – 事件时间戳
action (int) – 动作的几种标识
action_name (string) – 动作的文本描述
target (string) – 更改的事件的文本或细节
id (int) – 更改的识别文字
截图
2.14 新版功能.
- GET /api/screenshots/
返回屏幕截图字符串信息的列表。
参见
屏幕截图对象属性记录在
GET /api/screenshots/(int:id)/
。
- GET /api/screenshots/(int: id)/
返回与屏幕截图信息有关的信息。
- 参数
id (int) – 截图 ID
- 响应 JSON 对象
name (string) – 屏幕截图的名称
component (string) – 相关组件对象的 URL
file_url (string) – 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/
units (array) – 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- GET /api/screenshots/(int: id)/file/
下载屏幕截图的图片。
- 参数
id (int) – 截图 ID
- POST /api/screenshots/(int: id)/file/
替换屏幕截图。
- 参数
id (int) – 截图 ID
- 表单参数
file image – 上传文件
CURL 示例:
curl -X POST \ -F image=@image.png \ -H "Authorization: Token TOKEN" \ http://example.com/api/screenshots/1/file/
- POST /api/screenshots/(int: id)/units/
与屏幕截图相关的源字符串。
- 参数
id (int) – 截图 ID
- 表单参数
string unit_id – 单元 ID
- 响应 JSON 对象
name (string) – 屏幕截图的名称
translation (string) – 相关翻译对象的 URL
file_url (string) – 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/
units (array) – 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- DELETE /api/screenshots/(int: id)/units/(int: unit_id)
删除与截图关联的源字符串。
- 参数
id (int) – 截图 ID
unit_id – 源字符串单元 ID
- POST /api/screenshots/
新建新的屏幕截图。
- 表单参数
file image – 上传文件
string name – 截图名称
string project_slug – 项目标识串
string component_slug – 组件标识串
string language_code – 语言代码
- 响应 JSON 对象
name (string) – 屏幕截图的名称
component (string) – 相关组件对象的 URL
file_url (string) – 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/
units (array) – 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- PATCH /api/screenshots/(int: id)/
编辑截屏的部分信息。
- 参数
id (int) – 截图 ID
- 响应 JSON 对象
name (string) – 屏幕截图的名称
component (string) – 相关组件对象的 URL
file_url (string) – 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/
units (array) – 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- PUT /api/screenshots/(int: id)/
编辑截屏的完整信息。
- 参数
id (int) – 截图 ID
- 响应 JSON 对象
name (string) – 屏幕截图的名称
component (string) – 相关组件对象的 URL
file_url (string) – 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/
units (array) – 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- DELETE /api/screenshots/(int: id)/
删除截图。
- 参数
id (int) – 截图 ID
附加组件
4.4.1 新版功能.
- GET /api/addons/
返回附加组件的列表。
参见
附加组件对象属性记录在
GET /api/units/(int:id)/
。
- GET /api/addons/(int: id)/
返回有关附加组件的信息。
- 参数
id (int) – 附加组件 ID
- 响应 JSON 对象
name (string) – 组件名称
component (string) – 相关组件对象的 URL
configuration (object) – 最优附加组件配置
参见
- POST /api/components/(string: project)/(string: component)/addons/
创建新附加组件。
- 参数
project_slug (string) – 项目标识串
component_slug (string) – 组件标识串
- 请求 JSON 对象
name (string) – 组件名称
configuration (object) – 最优附加组件配置
- PATCH /api/addons/(int: id)/
编辑附加组件的部分信息。
- 参数
id (int) – 附加组件 ID
- 响应 JSON 对象
configuration (object) – 最优附加组件配置
- PUT /api/addons/(int: id)/
编辑附加组件的完整信息。
- 参数
id (int) – 附加组件 ID
- 响应 JSON 对象
configuration (object) – 最优附加组件配置
- DELETE /api/addons/(int: id)/
删除附加组件。
- 参数
id (int) – 附加组件 ID
组件列表
4.0 新版功能.
- GET /api/component-lists/
返回一个组件列表的列表。
参见
组件列表对象属性记录在
GET /api/component-lists/(str:slug)/
。
- GET /api/component-lists/(str: slug)/
返回组件列表的信息。
- 参数
slug (string) – 组件列表的标识串
- 响应 JSON 对象
name (string) – 组件列表的名称
slug (string) – 组件列表的表示串
show_dashboard (boolean) – 是否在控制台上显示
components (array) – 相关联组件的连接;请参见
GET /api/components/(string:project)/(string:component)/
auto_assign (array) – 自动分配规则
- PUT /api/component-lists/(str: slug)/
更改组件列表参数。
- 参数
slug (string) – 组件列表的标识串
- 请求 JSON 对象
name (string) – 组件列表的名称
slug (string) – 组件列表的表示串
show_dashboard (boolean) – 是否在控制台上显示
- PATCH /api/component-lists/(str: slug)/
更改组件列表参数。
- 参数
slug (string) – 组件列表的标识串
- 请求 JSON 对象
name (string) – 组件列表的名称
slug (string) – 组件列表的表示串
show_dashboard (boolean) – 是否在控制台上显示
- DELETE /api/component-lists/(str: slug)/
删除组件列表。
- 参数
slug (string) – 组件列表的标识串
- POST /api/component-lists/(str: slug)/components/
使组件与组件列表相关。
- 参数
slug (string) – 组件列表的标识串
- 表单参数
string component_id – 组件 ID
- DELETE /api/component-lists/(str: slug)/components/(str: component_slug)
将组件与组件列表接触相关性。
- 参数
slug (string) – 组件列表的标识串
component_slug (string) – 组件标识串
术语表
在 4.5 版更改: Glossaries are now stored as regular components, translations and strings, please use respective API instead.
任务
4.4 新版功能.
- GET /api/tasks/
任务列表当前不可用。
- GET /api/tasks/(str: uuid)/
返回任务信息
- 参数
uuid (string) – 任务 UUID
- 响应 JSON 对象
completed (boolean) – 任务是否已完成
progress (int) – 任务进度百分比
result (object) – 任务结果或过程细节
log (string) – 任务日志
Metrics
- GET /api/metrics/
Returns server metrics.
- 响应 JSON 对象
units (int) – 单元数量
units_translated (int) – 已翻译单元数量
users (int) – 用户数量
changes (int) – 更改的数量
projects (int) – 项目数
components" (int) – 组件数
translations" (int) – 翻译数
languages" (int) – 所用语言数量
checks" (int) – 触发的质量检查数
configuration_errors" (int) – 配置错误数
suggestions" (int) – 待处理建议数
celery_queues (object) – Celery 队列长度,见 使用 Celery 的后台任务
name (string) – 配置的服务器名
通知钩子
通知钩子允许外部应用来通知 Weblate 版本控制系统(VCS)仓库已经更新。
可以为项目、组件和翻译使用仓库端点来更新各自的仓库;文档请参见 POST /api/projects/(string:project)/repository/
。
- GET /hooks/update/(string: project)/(string: component)/
2.6 版后已移除: 请使用
POST /api/components/(string:project)/(string:component)/repository/
来替代,它使用 ACL 限制的身份验证而工作正常。触发组件的更新(从版本控制系统 VCS 拉取并扫描翻译的更改)。
- GET /hooks/update/(string: project)/
2.6 版后已移除: 请使用
POST /api/projects/(string:project)/repository/
来替代,它使用 ACL 限制的身份验证而工作正常。触发项目中所有组件的更新(从版本控制系统 VCS 拉取并扫描翻译的更改)。
- POST /hooks/github/
处理 Github 通知与自动更新匹配组件的特殊钩子。
注解
Github 包括了对通知 Weblate 的直接支持:在仓库设置中启动 Weblate 服务钩子,并将 URL 设置为你的 Weblate 安装的 URL。
参见
- 从 GitHub 自动接收更改
关于设置 Github 集成的指令
- https://docs.github.com/en/github/extending-github/about-webhooks
GitHub Webhooks 的一般信息
ENABLE_HOOKS
关于对整个 Weblate 启动钩子
- POST /hooks/gitlab/
处理 GitLab 通知并自动更新匹配组件的特殊钩子。
参见
- 从 GitLab 自动接收更改
关于设置 GitLab 集成的指示
- https://docs.gitlab.com/ee/user/project/integrations/webhooks.html
关于 GitLab Webhooks 的一般信息
ENABLE_HOOKS
关于对整个 Weblate 启动钩子
- POST /hooks/bitbucket/
处理 Bitbucket 通知并自动更新匹配的组件的特殊钩子。
参见
- 从 Bitbucket 自动接收更改
关于设置 Bitbucket 集成的指示
- https://support.atlassian.com/bitbucket-cloud/docs/manage-webhooks/
关于 Bitbucket Webhooks 的一般信息
ENABLE_HOOKS
关于对整个 Weblate 启动钩子
- POST /hooks/pagure/
3.3 新版功能.
处理 Pagure 通知并自动更新匹配的组件的特殊钩子。
参见
- 从 Pagure 自动接受更改
关于设置 Pagure 集成的指示
- https://docs.pagure.org/pagure/usage/using_webhooks.html
关于 Pagure Webhooks 的一般信息
ENABLE_HOOKS
关于对整个 Weblate 启动钩子
- POST /hooks/azure/
3.8 新版功能.
处理 Azure Repos 通知并自动更新匹配的组件的特殊钩子。
参见
- 从 Azure Repos 自动接收更改
关于设置 Azure 集成的指示
- https://docs.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops
关于 Azure Repos Web Hooks 的一般信息
ENABLE_HOOKS
关于对整个 Weblate 启动钩子
- POST /hooks/gitea/
3.9 新版功能.
处理 Gitea Webhook 通知并自动更新匹配的组件的特殊钩子。
参见
- 从 Gitea Repos 自动接收更改
关于设置 Gitea 集成的指示
- https://docs.gitea.io/en-us/webhooks/
关于 Gitea Webhooks 的一般信息
ENABLE_HOOKS
关于对整个 Weblate 启动钩子
- POST /hooks/gitee/
3.9 新版功能.
处理 Gitee Webhook 通知并自动更新匹配的组件的特殊钩子。
参见
- 从 Gitee Repos 自动接收更改
关于设置 Gitee 集成的指示
- https://gitee.com/help/categories/40
关于 Gitee Webhooks 的一般信息
ENABLE_HOOKS
关于对整个 Weblate 启动钩子
导出
Weblate 提供各种导出,允许进一步处理数据。
- GET /exports/stats/(string: project)/(string: component)/
- 查询参数
format (string) – 输出格式:
json
或csv
2.6 版后已移除: 请替代使用
GET /api/components/(string:project)/(string:component)/statistics/
和GET /api/translations/(string:project)/(string:component)/(string:language)/statistics/
;它也允许访问 ACL 控制的项目。为给定的组件以给定的格式检索统计数据。
请求的示例:
GET /exports/stats/weblate/main/ HTTP/1.1 Host: example.com Accept: application/json, text/javascript
响应的示例:
HTTP/1.1 200 OK Vary: Accept Content-Type: application/json [ { "code": "cs", "failing": 0, "failing_percent": 0.0, "fuzzy": 0, "fuzzy_percent": 0.0, "last_author": "Michal Čihař", "last_change": "2012-03-28T15:07:38+00:00", "name": "Czech", "total": 436, "total_words": 15271, "translated": 436, "translated_percent": 100.0, "translated_words": 3201, "url": "http://hosted.weblate.org/engage/weblate/cs/", "url_translate": "http://hosted.weblate.org/projects/weblate/main/cs/" }, { "code": "nl", "failing": 21, "failing_percent": 4.8, "fuzzy": 11, "fuzzy_percent": 2.5, "last_author": null, "last_change": null, "name": "Dutch", "total": 436, "total_words": 15271, "translated": 319, "translated_percent": 73.2, "translated_words": 3201, "url": "http://hosted.weblate.org/engage/weblate/nl/", "url_translate": "http://hosted.weblate.org/projects/weblate/main/nl/" }, { "code": "el", "failing": 11, "failing_percent": 2.5, "fuzzy": 21, "fuzzy_percent": 4.8, "last_author": null, "last_change": null, "name": "Greek", "total": 436, "total_words": 15271, "translated": 312, "translated_percent": 71.6, "translated_words": 3201, "url": "http://hosted.weblate.org/engage/weblate/el/", "url_translate": "http://hosted.weblate.org/projects/weblate/main/el/" } ]
RSS 订阅源
翻译的变更会导出到 RSS 订阅源中。
- GET /exports/rss/(string: project)/(string: component)/(string: language)/
返回带有翻译近期变更的 RSS 订阅源。
- GET /exports/rss/(string: project)/(string: component)/
返回带有组件近期变更的 RSS 订阅源。
- GET /exports/rss/(string: project)/
返回带有项目近期变更的 RSS 订阅源。
- GET /exports/rss/language/(string: language)/
返回带有语言近期变更的 RSS 订阅源。
- GET /exports/rss/
返回带有 Weblate 实例近期变更的 RSS 订阅源。
Weblate 客户端
2.7 新版功能: 自从 Weblate 2.7 以来,已经有完整的 wlc 实用程序支持。如果您使用的是旧版本,则可能会与 API 发生某些不兼容。
安装
Weblate 客户端是分开上市的,包括 Python 模块。要使用下面的命令,您需要安装 wlc
:
pip3 install wlc
Docker 用法
The Weblate Client is also available as a Docker image.
The image is published on Docker Hub: https://hub.docker.com/r/weblate/wlc
正在安装:
docker pull weblate/wlc
The Docker container uses Weblate’s default settings and connects to the API deployed in localhost. The API URL and API_KEY can be configured through the arguments accepted by Weblate.
The command to launch the container uses the following syntax:
docker run --rm weblate/wlc [WLC_ARGS]
示例:
docker run --rm weblate/wlc --url https://hosted.weblate.org/api/ list-projects
You might want to pass your 配置文件 to the Docker container, the
easiest approach is to add your current directory as /home/weblate
volume:
docker run --volume $PWD:/home/weblate --rm weblate/wlc show
入门
wlc 配置存储在 ~/.config/weblate
中(其他位置请参见 配置文件),请根据你的环境创建它:
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = APIKEY
然后,您可以在默认服务器上调用命令:
wlc ls
wlc commit sandbox/hello-world
参见
概要
wlc [arguments] <command> [options]
命令实际上指示应该执行哪个操作。
描述
Weblate 客户端是一个 Python 库和命令行实用程序,可使用 Weblate 的 REST API 远程管理 Weblate。命令行实用程序可以作为 wlc 调用,并且内置在 wlc
上。
参数
程序接受以下参数来定义输出格式或使用哪个Weblate实例。这些参数必须位于任何命令之前。
- --format {csv,json,text,html}
指定输出格式。
命令
以下命令可用:
- version
打印当前版本。
- list-languages
列出 Weblate 中使用的语言。
- list-projects
列出 Weblate 中的项目。
- list-components
列出 Weblate 中的组件。
- list-translations
列出 Weblate 中的翻译。
- show
显示 Weblate 对象(翻译,组件或项目)。
- ls
列出 Weblate 对象(翻译,组件或项目)。
- commit
提交在 Weblate 对象(翻译,组件或项目)中所做的更改。
- pull
拉取远程仓库的更改到 Weblate 对象中(翻译,组件或项目)。
- push
将 Weblate 对象更改推送到远程仓库(翻译,组件或项目)。
- reset
0.7 新版功能: 自 wlc 0.7 起受支持。
重置 Weblate 对象中的更改以匹配远程存储库(翻译,组件或项目)。
- cleanup
0.9 新版功能: 从 wlc 0.9 开始受支持。
删除 Weblate 对象中所有未跟踪的更改以匹配远程仓库(翻译,组件或项目)。
- repo
显示给定 Weblate 对象(翻译,组件或项目)的仓库状态。
- statistics
显示给定 Weblate 对象(翻译,组件或项目)的详细统计数据。
- lock-status
0.5 新版功能: 自 wlc 0.5 起受支持。
显示锁定状态。
- lock
0.5 新版功能: 自 wlc 0.5 起受支持。
锁定组件以防止在 Weblate 中进一步翻译。
- unlock
0.5 新版功能: 自 wlc 0.5 起受支持。
解锁 Weblate 组件的翻译。
- changes
0.7 新版功能: 从 wlc 0.7 和 Weblate 2.10 开始受支持。
显示给定对象的更改。
- download
0.7 新版功能: 自 wlc 0.7 起受支持。
下载翻译文件。
- --convert
转换文件格式,如果未指定,则在服务器上不进行任何转换,并且将文件原样下载到仓库中。
- --output
指定要保存输出的文件,如果未指定,则将其打印到 stdout。
- upload
0.9 新版功能: 从 wlc 0.9 开始受支持。
上传翻译文件。
- --overwrite
上传时覆盖现有翻译。
- --input
从中读取内容的文件,如果未指定,则从 stdin 中读取。
提示
You can get more detailed information on invoking individual commands by
passing --help
, for example: wlc ls --help
.
配置文件
.weblate
,.weblate.ini
,weblate.ini
在 1.6 版更改: 同时支持扩展名为`.ini`的文件。
每个项目的配置文件
C:\Users\NAME\AppData\weblate.ini
1.6 新版功能.
在 Windows 上使用配置文件。
~/.config/weblate
用户配置文件
/etc/xdg/weblate
系统范围的配置文件
该程序遵循 XDG 规范,因此您可以通过环境变量 XDG_CONFIG_HOME
或 XDG_CONFIG_DIRS
来调整配置文件的位置。在 Windows 系统上 `APPDATA``目录是配置文件的首选位置。
可以在 [weblate]
部分中配置以下设置(您可以通过 --config-section
进行自定义):
- key
用于访问 Weblate 的 API KEY。
- url
API 服务器网址,默认为
http://127.0.0.1:8000/api/
。
- translation
默认翻译的路径 —— 组件或项目。
配置文件是一个 INI 文件,例如:
[weblate]
url = https://hosted.weblate.org/api/
key = APIKEY
translation = weblate/application
另外,API 密钥可以存储在 [keys]
部分中:
[keys]
https://hosted.weblate.org/api/ = APIKEY
这样,您就可以在版本控制系统(VCS)仓库中使用 .weblate
配置时,将密钥存储在个人设置中,以便 wlc 知道它应该与哪个服务器通信。
例子
打印当前程序版本:
$ wlc version
version: 0.1
列出所有项目:
$ wlc list-projects
name: Hello
slug: hello
url: http://example.com/api/projects/hello/
web: https://weblate.org/
web_url: http://example.com/projects/hello/
您还可以指定 wlc 应该从事的项目:
$ cat .weblate
[weblate]
url = https://hosted.weblate.org/api/
translation = weblate/application
$ wlc show
branch: main
file_format: po
source_language: en
filemask: weblate/locale/*/LC_MESSAGES/django.po
git_export: https://hosted.weblate.org/git/weblate/application/
license: GPL-3.0+
license_url: https://spdx.org/licenses/GPL-3.0+
name: Application
new_base: weblate/locale/django.pot
project: weblate
repo: git://github.com/WeblateOrg/weblate.git
slug: application
template:
url: https://hosted.weblate.org/api/components/weblate/application/
vcs: git
web_url: https://hosted.weblate.org/projects/weblate/application/
通过此设置,可以轻松地提交当前项目中待定的更改:
$ wlc commit
Weblate 的 Python API
安装
Python API 是单独发布的,你需要安装 Weblate 客户端 (wlc) 才能拥有它。
pip install wlc
wlc
WeblateException
- exception wlc.WeblateException
所有异常的基类。
Weblate
- class wlc.Weblate(key='', url=None, config=None)
- 参数
key (str) – User key
url (str) – API server URL, if not specified default is used
config (wlc.config.WeblateConfig) – Configuration object, overrides any other parameters.
Access class to the API, define API key and optionally API URL.
- get(path)
- 参数
path (str) – Request path
- 返回类型
object
Performs a single API GET call.
- post(path, **kwargs)
- 参数
path (str) – Request path
- 返回类型
object
Performs a single API GET call.
wlc.config
WeblateConfig
- class wlc.config.WeblateConfig(section='wlc')
- 参数
section (str) – Configuration section to use
Configuration file parser following XDG specification.
- load(path=None)
- 参数
path (str) – Path from which to load configuration.
Loads configuration from a file, if none is specified, it loads from the wlc configuration file (
~/.config/wlc
) placed in your XDG configuration path (/etc/xdg/wlc
).
wlc.main
- wlc.main.main(settings=None, stdout=None, args=None)
- 参数
settings (list) – Settings to override as list of tuples
stdout (object) – stdout file object for printing output, uses
sys.stdout
as defaultargs (list) – Command-line arguments to process, uses
sys.args
as default
Main entry point for command-line interface.
- @wlc.main.register_command(command)
Decorator to register
Command
class in main parser used bymain()
.
Command
- class wlc.main.Command(args, config, stdout=None)
Main class for invoking commands.
配置手册
安装 Weblate
使用 Docker 安装
通过 dockerized Weblate 部署,您可以在几秒钟内启动并运行您的个人 Weblate 实例。Weblate 的所有依赖项已包含在内。PostgreSQL 被新建为默认数据库。
硬件要求
Weblate 应该可以在任何现代硬件上正常运行,以下是在单个主机(Weblate ,数据库和 Web 服务器)上运行 Weblate 所需的最低配置:
2 GB 的内存
2 个 CPU 核心
1 GB 的存储空间
内存越多越好——用于所有级别的缓存(文件系统,数据库和 Weblate )。
许多并发用户会增加所需的 CPU 内核数量。对于数百个翻译组件,推荐至少有 4 GB 的内存。
典型的数据库存储用量大约为每 1 百万单词 300 MB。克隆仓库所需的存储空间会变化,但 Weblate 试图通过浅克隆将其大小最小化。
注解
根据 Weblate 中管理的翻译大小,安装 Weblate 的实际要求差异很大。
安装
以下示例假设您拥有一个工作正常的 Docker 环境,并安装了 docker-compose
。请查看 Docker 文档以获取说明。
克隆 weblate-docker 存储库:
git clone https://github.com/WeblateOrg/docker-compose.git weblate-docker cd weblate-docker
使用您的设置创建一个
docker-compose.override.yml
文件。请参阅 Docker 环境变量 以获取环境变量的完整列表。version: '3' services: weblate: ports: - 80:8080 environment: WEBLATE_EMAIL_HOST: smtp.example.com WEBLATE_EMAIL_HOST_USER: user WEBLATE_EMAIL_HOST_PASSWORD: pass WEBLATE_SERVER_EMAIL: weblate@example.com WEBLATE_DEFAULT_FROM_EMAIL: weblate@example.com WEBLATE_SITE_DOMAIN: weblate.example.com WEBLATE_ADMIN_PASSWORD: password for the admin user WEBLATE_ADMIN_EMAIL: weblate.admin@example.com
注解
如果未设置
WEBLATE_ADMIN_PASSWORD
,则使用首次启动时显示的随机密码创建管理员用户。提供的例子使 Weblate 侦听端口 80,在
docker-compose.override.yml
文件中编辑端口映射来更改。启动 Weblate 容器:
docker-compose up
享受您的 Weblate 部署,可以在 weblate
容器的端口 80 上进行访问。
在 2.15-2 版更改: 最近更改了设置,以前有单独的 web 服务器容器,因为 2.15-2 开始,web 服务器已嵌入 Weblate 容器中。
在 3.7.1-6 版更改: 在 2019 年 7 月(从 3.7.1-6 tag 开始)中,容器未以 root 用户身份运行。这已将裸露端口从 80 更改为 8080。
参见
Choosing Docker hub tag
You can use following tags on Docker hub, see https://hub.docker.com/r/weblate/weblate/tags/ for full list of available ones.
标签名称 |
描述 |
用例 |
---|---|---|
|
Weblate stable release, matches latest tagged release |
Rolling updates in a production environment |
|
Weblate 稳定发行版 |
生产环境下定义良好的部署 |
|
Weblate stable release with development changes in the Docker container (for example updated dependencies) |
Rolling updates in a staging environment |
|
Weblate stable release with development changes in the Docker container (for example updated dependencies) |
Well defined deploy in a staging environment |
|
Development version Weblate from Git |
Rollling updates to test upcoming Weblate features |
|
Development version Weblate from Git |
Well defined deploy to test upcoming Weblate features |
Every image is tested by our CI before it gets published, so even the bleeding version should be quite safe to use.
具有 HTTPS 支持的 Docker 容器
请参阅 安装 以获取常规部署说明,本节仅提及与之相比的差异。
使用自己的 SSL 证书
3.8-3 新版功能.
如果您要使用自己的 SSL 证书,只需将文件放入 Weblate 数据卷中(请参阅 Docker 容器卷):
ssl/fullchain.pem
包含证书,包括任何需要的 CA 证书ssl/privkey.pem
包含有私钥
拥有这两个文件的用户必须与启动 docker 容器并将文件掩码设置为 600
(仅拥有用户可读可写)的用户为同一用户。
此外,Weblate 容器现在将在端口 4443 上接受 SSL 连接,您将要在 docker compose override 中包括 HTTPS 的端口转发:
version: '3'
services:
weblate:
ports:
- 80:8080
- 443:4443
如果您已经在同一服务器上托管其他站点,则反向代理(例如 NGINX )可能会使用端口 80
和 443
。要将 HTTPS 连接从 NGINX 传递到 docker 容器,可以使用以下配置:
server {
listen 443;
listen [::]:443;
server_name <SITE_URL>;
ssl_certificate /etc/letsencrypt/live/<SITE>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<SITE>/privkey.pem;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass https://127.0.0.1:<EXPOSED_DOCKER_PORT>;
}
}
将 <SITE_URL>
,<SITE>
和 <EXPOSED_DOCKER_PORT>
替换为您环境中的实际值。
使用 Let’s Encrypt 自动生成 SSL 证书
如果要在公共安装中使用 Let’s Encrypt 自动生成的 SSL 证书,则需要在其他 Docker 容器中添加反向 HTTPS 代理,这将使用 https-portal。这是在 docker-compose-https.yml
文件中使用的。然后使用您的设置创建一个 docker-compose-https.override.yml
文件:
version: '3'
services:
weblate:
environment:
WEBLATE_EMAIL_HOST: smtp.example.com
WEBLATE_EMAIL_HOST_USER: user
WEBLATE_EMAIL_HOST_PASSWORD: pass
WEBLATE_SITE_DOMAIN: weblate.example.com
WEBLATE_ADMIN_PASSWORD: password for admin user
https-portal:
environment:
DOMAINS: 'weblate.example.com -> http://weblate:8080'
每当调用 docker-compose 时,您都需要将两个文件都传递给它,然后执行以下操作:
docker-compose -f docker-compose-https.yml -f docker-compose-https.override.yml build
docker-compose -f docker-compose-https.yml -f docker-compose-https.override.yml up
升级 Docker 容器
通常,只更新 Weblate 容器并保持 PostgreSQL 容器为您的版本是一个好主意,因为升级 PostgreSQL 会很痛苦,并且在大多数情况下不会带来很多好处。
您可以通过坚持使用现有的 docker-compose,并且只是拉取最新镜像,然后重新启动,来执行此操作:
# Fetch latest versions of the images
docker-compose pull
# Stop and destroy the containers
docker-compose down
# Spawn new containers in the background
docker-compose up -d
# Follow the logs during upgrade
docker-compose logs -f
Weblate 数据库应在首次启动时自动迁移,并且不需要其他手动操作。
注解
Weblate 不支持跨 3.0 的升级。如果您使用的是 2.x 系列,并且要升级到 3.x,请首先升级到最新的 3.0.1-x(在撰写本文时为 3.0.1-7
)镜像,它将进行迁移和然后继续升级到较新版本。
您可能还想更新 docker-compose
仓库,尽管在大多数情况下并不需要。在这种情况下,请注意 PostgreSQL 版本的更改,因为升级数据库并不容易,请参见 GitHub issue 以获取更多信息。
管理员登录
设置容器之后,您可以使用 WEBLATE_ADMIN_PASSWORD
中提供的密码以 管理员 用户身份登录,或者如果未设置该密码,则在首次启动时生成随机密码。
要重置 管理员 密码,请在 WEBLATE_ADMIN_PASSWORD
设置为新密码的情况下重启容器。
Number of processes and memory consumption
The number of worker processes for both uWSGI and Celery is determined automatically based on number of CPUs. This works well for most cloud virtual machines as these typically have few CPUs and good amount of memory.
在你有很多 CPU 核心并且碰到内存用尽问题情况下,尝试减少 worker 的数量:
environment:
WEBLATE_WORKERS: 2
你还可以微调单个 worker 类别:
environment:
WEB_WORKERS: 4
CELERY_MAIN_OPTIONS: --concurrency 2
CELERY_NOTIFY_OPTIONS: --concurrency 1
CELERY_TRANSLATE_OPTIONS: --concurrency 1
横向扩展
4.6 新版功能.
警告
该功能目前处于技术预览阶段。
You can run multiple Weblate containers to scale the service horizontally. The
/app/data
volume has to be shared by all containers, it is recommended
to use cluster filesystem such as GlusterFS for this. The /app/cache
volume should be separate for each container.
Each Weblate container has defined role using WEBLATE_SERVICE
environment variable. Please follow carefully the documentation as some of the
services should be running just once in the cluster and the ordering of the
services matters as well.
You can find example setup in the docker-compose
repo as
docker-compose-split.yml.
Docker 环境变量
可以使用环境变量在 Docker 容器中设置许多 Weblate 的 配置 :
通用设置
- WEBLATE_LOGLEVEL
配置日志记录的详细程度。
- WEBLATE_SITE_TITLE
更改所有页面页眉上显示的站点标题。
- WEBLATE_SITE_DOMAIN
配置站点域名。此参数为必填项。
参见
- WEBLATE_ADMIN_NAME
- WEBLATE_ADMIN_EMAIL
配置站点管理员的姓名和电子邮件。它用于
ADMINS
设置和创建 管理员 用户(有关此信息,请参阅WEBLATE_ADMIN_PASSWORD
)。示例:
environment: WEBLATE_ADMIN_NAME: Weblate admin WEBLATE_ADMIN_EMAIL: noreply@example.com
- WEBLATE_ADMIN_PASSWORD
设置 管理员 用户的密码。
如果未设置并且 管理员 用户不存在,则会使用首次启动容器时显示的随机密码来创建它。
如果未设置并且 管理员 用户存在,则不执行任何操作。
如果设置,则在每次容器启动时都会对 管理员 用户进行调整,以匹配
WEBLATE_ADMIN_PASSWORD
,WEBLATE_ADMIN_NAME
和WEBLATE_ADMIN_EMAIL
。
警告
将密码存储在配置文件中可能会带来安全风险。考虑仅将此变量用于初始设置(或让 Weblate 在初始启动时生成随机密码)或用于密码恢复。
- WEBLATE_ADMIN_PASSWORD_FILE
设置指向包含 管理员 用户密码的一个文件。
- WEBLATE_SERVER_EMAIL
The email address that error messages are sent from.
- WEBLATE_DEFAULT_FROM_EMAIL
配置外发电子邮件的地址。
- WEBLATE_CONTACT_FORM
Configures contact form behavior, see
CONTACT_FORM
.
- WEBLATE_ALLOWED_HOSTS
使用
ALLOWED_HOSTS
配置允许的 HTTP 主机名。默认为
*
来允许所有的主机名称。示例:
environment: WEBLATE_ALLOWED_HOSTS: weblate.example.com,example.com
参见
- WEBLATE_REGISTRATION_OPEN
通过切换
REGISTRATION_OPEN
配置是否打开注册。示例:
environment: WEBLATE_REGISTRATION_OPEN: 0
- WEBLATE_REGISTRATION_ALLOW_BACKENDS
配置可用于通过
REGISTRATION_ALLOW_BACKENDS
创建新帐户的身份验证方法。示例:
environment: WEBLATE_REGISTRATION_OPEN: 0 WEBLATE_REGISTRATION_ALLOW_BACKENDS: azuread-oauth2,azuread-tenant-oauth2
- WEBLATE_TIME_ZONE
在 Weblate 中配置使用的时区,请参阅
TIME_ZONE
。注解
为了更改 Docker 自己的时区,使用
TZ
环境变量。示例:
environment: WEBLATE_TIME_ZONE: Europe/Prague
- WEBLATE_ENABLE_HTTPS
让 Weblate 假定在反向 HTTPS 代理后面操作,这使 Weblate 在电子邮件和 API 链接中使用 HTTPS ,或者在 cookies 上设置安全标记。
提示
可能的警告请参见
ENABLE_HTTPS
文档。注解
这不会使 Weblate 容器接受 HTTPS 连接,您同样需要配置它,例子请参见 具有 HTTPS 支持的 Docker 容器 。
示例:
environment: WEBLATE_ENABLE_HTTPS: 1
- WEBLATE_IP_PROXY_HEADER
让 Weblate 从任何给定的 HTTP 标头中取回 IP 地址。在使用 Weblate 容器之前的反向代理时使用它。
允许
IP_BEHIND_REVERSE_PROXY
并设置IP_PROXY_HEADER
。注解
格式必须符合 Django 的要求。 Django transforms 原始 HTTP 标头如下命名:
将所有字符装换为大写
用下划线替换任何连字符
预置
HTTP_
前缀
所以
X-Forwarded-For
将被映射到HTTP_X_FORWARDED_FOR
。示例:
environment: WEBLATE_IP_PROXY_HEADER: HTTP_X_FORWARDED_FOR
- WEBLATE_SECURE_PROXY_SSL_HEADER
代表 HTTP 标头/值的组合的元组,用于表达请求,这样的元组是安全的。当 Weblate 在进行终止SSL 的反向代理之后运行时,这是需要的,终止 SSL 不通过标准 HTTPS 标头。
示例:
environment: WEBLATE_SECURE_PROXY_SSL_HEADER: HTTP_X_FORWARDED_PROTO,https
- WEBLATE_REQUIRE_LOGIN
启用
REQUIRE_LOGIN
而在整个 Weblate 上强制认证。示例:
environment: WEBLATE_REQUIRE_LOGIN: 1
- WEBLATE_LOGIN_REQUIRED_URLS_EXCEPTIONS
- WEBLATE_ADD_LOGIN_REQUIRED_URLS_EXCEPTIONS
- WEBLATE_REMOVE_LOGIN_REQUIRED_URLS_EXCEPTIONS
使用
LOGIN_REQUIRED_URLS_EXCEPTIONS
来为整个 Webate 安装所需的身份验证添加 URL 例外。可以替换整个设置,或者使用
ADD
和REMOVE
变量修改默认值。
- WEBLATE_GOOGLE_ANALYTICS_ID
通过更改
GOOGLE_ANALYTICS_ID
为 Google Analytics(分析)配置 ID。
- WEBLATE_GITHUB_USERNAME
通过更改
GITHUB_USERNAME
来配置用于 GitHub 拉取请求的 GitHub 用户名。参见
- WEBLATE_GITHUB_TOKEN
4.3 新版功能.
通过更改
GITHUB_TOKEN
,为 Github 通过 API 的拉取请求来配置 GitHub 的个人访问令牌。参见
- WEBLATE_GITLAB_USERNAME
通过更改
GITLAB_USERNAME
来配置用于 GitLab 合并请求的 GitLab 用户名参见
- WEBLATE_GITLAB_TOKEN
通过更改
GITLAB_TOKEN
,为 GitLab 通过 API 的合并请求来配置 GitLab 的个人访问令牌参见
- WEBLATE_PAGURE_TOKEN
通过更改
PAGURE_TOKEN
,为通过API的Pagure合并请求配置Pagure个人访问令牌参见
- WEBLATE_SIMPLIFY_LANGUAGES
配置语言简化策略,请参见
SIMPLIFY_LANGUAGES
。
- WEBLATE_DEFAULT_ACCESS_CONTROL
为新项目配置默认的 访问控制 ,请参见
DEFAULT_ACCESS_CONTROL
。
- WEBLATE_DEFAULT_RESTRICTED_COMPONENT
为新组件的 受限制的访问 配置默认值,请参见
DEFAULT_RESTRICTED_COMPONENT
。
- WEBLATE_DEFAULT_TRANSLATION_PROPAGATION
为新组件的 允许同步翻译 配置默认值,请参见
DEFAULT_TRANSLATION_PROPAGATION
。
- WEBLATE_DEFAULT_COMMITER_EMAIL
- WEBLATE_DEFAULT_COMMITER_NAME
- WEBLATE_DEFAULT_SHARED_TM
- WEBLATE_AKISMET_API_KEY
配置 Akismet API 密钥,请参见
AKISMET_API_KEY
。
- WEBLATE_GPG_IDENTITY
配置提交的 GPG 签名,请参见
WEBLATE_GPG_IDENTITY
。
- WEBLATE_URL_PREFIX
配置 Weblate 运行的 URL 前缀,请参见
URL_PREFIX
。
- WEBLATE_SILENCED_SYSTEM_CHECKS
配置您不想要显示的检查,请参见
SILENCED_SYSTEM_CHECKS
。
- WEBLATE_CSP_SCRIPT_SRC
- WEBLATE_CSP_IMG_SRC
- WEBLATE_CSP_CONNECT_SRC
- WEBLATE_CSP_STYLE_SRC
- WEBLATE_CSP_FONT_SRC
允许定制
Content-Security-Policy
HTTP 标头。
- WEBLATE_LICENSE_FILTER
配置
LICENSE_FILTER
.
- WEBLATE_LICENSE_REQUIRED
- WEBLATE_WEBSITE_REQUIRED
- WEBLATE_HIDE_VERSION
配置
HIDE_VERSION
。
- WEBLATE_BASIC_LANGUAGES
配置
BASIC_LANGUAGES
.
- WEBLATE_DEFAULT_AUTO_WATCH
- WEBLATE_RATELIMIT_ATTEMPTS
- WEBLATE_RATELIMIT_LOCKOUT
- WEBLATE_RATELIMIT_WINDOW
4.6 新版功能.
配置速率限制器。
提示
You can set configuration for any rate limiter scopes. To do that add
WEBLATE_
prefix to any of setting described in 频次限制.
- WEBLATE_ENABLE_AVATARS
4.6.1 新版功能.
配置
ENABLE_AVATARS
.
- WEBLATE_LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH
4.9 新版功能.
- WEBLATE_SSH_EXTRA_ARGS
4.9 新版功能.
配置
SSH_EXTRA_ARGS
。
- WEBLATE_BORG_EXTRA_ARGS
4.9 新版功能.
配置
BORG_EXTRA_ARGS
。
机器翻译设置
提示
Configuring API key for a service automatically configures it in MT_SERVICES
.
- WEBLATE_MT_APERTIUM_APY
启用 Apertium 机器翻译并设置
MT_APERTIUM_APY
- WEBLATE_MT_AWS_REGION
- WEBLATE_MT_AWS_ACCESS_KEY_ID
- WEBLATE_MT_AWS_SECRET_ACCESS_KEY
配置 AWS 机器翻译。
environment: WEBLATE_MT_AWS_REGION: us-east-1 WEBLATE_MT_AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE WEBLATE_MT_AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- WEBLATE_MT_DEEPL_KEY
允许 DeepL 机器翻译,并设置
MT_DEEPL_KEY
- WEBLATE_MT_DEEPL_API_URL
配置要使用的 DeepL API 版本,见
MT_DEEPL_API_URL
.
- WEBLATE_MT_LIBRETRANSLATE_KEY
启用 LibreTranslate 机器翻译并设置
MT_LIBRETRANSLATE_KEY
- WEBLATE_MT_LIBRETRANSLATE_API_URL
配置要使用的 LibreTranslate API 实例,见
MT_LIBRETRANSLATE_API_URL
。
- WEBLATE_MT_GOOGLE_KEY
允许 谷歌翻译 并设置
MT_GOOGLE_KEY
- WEBLATE_MT_GOOGLE_CREDENTIALS
- WEBLATE_MT_GOOGLE_PROJECT
- WEBLATE_MT_GOOGLE_LOCATION
- WEBLATE_MT_MICROSOFT_COGNITIVE_KEY
- WEBLATE_MT_MICROSOFT_ENDPOINT_URL
设置
MT_MICROSOFT_ENDPOINT_URL
,请注意,这应该只包含域名。
- WEBLATE_MT_MICROSOFT_REGION
- WEBLATE_MT_MICROSOFT_BASE_URL
- WEBLATE_MT_MODERNMT_KEY
允许 ModernMT 并设置
MT_MODERNMT_KEY
。
- WEBLATE_MT_MYMEMORY_ENABLED
允许 MyMemory 机器翻译,并将
MT_MYMEMORY_EMAIL
设置到WEBLATE_ADMIN_EMAIL
。示例:
environment: WEBLATE_MT_MYMEMORY_ENABLED: 1
- WEBLATE_MT_MICROSOFT_TERMINOLOGY_ENABLED
允许 微软术语服务 机器翻译。
environment: WEBLATE_MT_MICROSOFT_TERMINOLOGY_ENABLED: 1
- WEBLATE_MT_SAP_BASE_URL
- WEBLATE_MT_SAP_SANDBOX_APIKEY
- WEBLATE_MT_SAP_USERNAME
- WEBLATE_MT_SAP_PASSWORD
身份验证设置
- WEBLATE_AUTH_LDAP_SERVER_URI
- WEBLATE_AUTH_LDAP_USER_DN_TEMPLATE
- WEBLATE_AUTH_LDAP_USER_ATTR_MAP
- WEBLATE_AUTH_LDAP_BIND_DN
- WEBLATE_AUTH_LDAP_BIND_PASSWORD
- WEBLATE_AUTH_LDAP_CONNECTION_OPTION_REFERRALS
- WEBLATE_AUTH_LDAP_USER_SEARCH
- WEBLATE_AUTH_LDAP_USER_SEARCH_FILTER
- WEBLATE_AUTH_LDAP_USER_SEARCH_UNION
- WEBLATE_AUTH_LDAP_USER_SEARCH_UNION_DELIMITER
LDAP 身份验证配置。
直接绑定的例子:
environment: WEBLATE_AUTH_LDAP_SERVER_URI: ldap://ldap.example.org WEBLATE_AUTH_LDAP_USER_DN_TEMPLATE: uid=%(user)s,ou=People,dc=example,dc=net # map weblate 'full_name' to ldap 'name' and weblate 'email' attribute to 'mail' ldap attribute. # another example that can be used with OpenLDAP: 'full_name:cn,email:mail' WEBLATE_AUTH_LDAP_USER_ATTR_MAP: full_name:name,email:mail
搜索与绑定的例子:
environment: WEBLATE_AUTH_LDAP_SERVER_URI: ldap://ldap.example.org WEBLATE_AUTH_LDAP_BIND_DN: CN=ldap,CN=Users,DC=example,DC=com WEBLATE_AUTH_LDAP_BIND_PASSWORD: password WEBLATE_AUTH_LDAP_USER_ATTR_MAP: full_name:name,email:mail WEBLATE_AUTH_LDAP_USER_SEARCH: CN=Users,DC=example,DC=com
联合搜索与绑定的例子:
environment: WEBLATE_AUTH_LDAP_SERVER_URI: ldap://ldap.example.org WEBLATE_AUTH_LDAP_BIND_DN: CN=ldap,CN=Users,DC=example,DC=com WEBLATE_AUTH_LDAP_BIND_PASSWORD: password WEBLATE_AUTH_LDAP_USER_ATTR_MAP: full_name:name,email:mail WEBLATE_AUTH_LDAP_USER_SEARCH_UNION: ou=users,dc=example,dc=com|ou=otherusers,dc=example,dc=com
针对 Active Directory 的搜索与绑定的示例:
environment: WEBLATE_AUTH_LDAP_BIND_DN: CN=ldap,CN=Users,DC=example,DC=com WEBLATE_AUTH_LDAP_BIND_PASSWORD: password WEBLATE_AUTH_LDAP_SERVER_URI: ldap://ldap.example.org WEBLATE_AUTH_LDAP_CONNECTION_OPTION_REFERRALS: 0 WEBLATE_AUTH_LDAP_USER_ATTR_MAP: full_name:name,email:mail WEBLATE_AUTH_LDAP_USER_SEARCH: CN=Users,DC=example,DC=com WEBLATE_AUTH_LDAP_USER_SEARCH_FILTER: (sAMAccountName=%(user)s)
参见
- WEBLATE_SOCIAL_AUTH_GITHUB_KEY
- WEBLATE_SOCIAL_AUTH_GITHUB_SECRET
- WEBLATE_SOCIAL_AUTH_GITHUB_ORG_KEY
- WEBLATE_SOCIAL_AUTH_GITHUB_ORG_SECRET
- WEBLATE_SOCIAL_AUTH_GITHUB_ORG_NAME
- WEBLATE_SOCIAL_AUTH_GITHUB_TEAM_KEY
- WEBLATE_SOCIAL_AUTH_GITHUB_TEAM_SECRET
- WEBLATE_SOCIAL_AUTH_GITHUB_TEAM_ID
允许 GitHub 身份验证 。
- WEBLATE_SOCIAL_AUTH_BITBUCKET_KEY
- WEBLATE_SOCIAL_AUTH_BITBUCKET_SECRET
允许 Bitbucket 身份验证 。
- WEBLATE_SOCIAL_AUTH_FACEBOOK_KEY
- WEBLATE_SOCIAL_AUTH_FACEBOOK_SECRET
允许 Facebook OAuth 2.
- WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_KEY
- WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET
- WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS
- WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS
允许 Google OAuth 2 。
- WEBLATE_SOCIAL_AUTH_GITLAB_KEY
- WEBLATE_SOCIAL_AUTH_GITLAB_SECRET
- WEBLATE_SOCIAL_AUTH_GITLAB_API_URL
允许 GitLab OAuth 2 。
- WEBLATE_SOCIAL_AUTH_AZUREAD_OAUTH2_KEY
- WEBLATE_SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET
启用 Azure Active Directory 身份验证,请参见 微软 Azure Active Directory。
- WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY
- WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET
- WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID
启用支持 Azure Active Directory 租户的身份验证,请参见 微软 Azure Active Directory。
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_KEY
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_SECRET
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_PUBLIC_KEY
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_ALGORITHM
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL
允许 Keycloak 身份验证,请参见 documentation 。
您可以通过将后面的变量设置为任何值,使用 Linux 销售商身份验证服务来允许身份验证。
- WEBLATE_SOCIAL_AUTH_FEDORA
- WEBLATE_SOCIAL_AUTH_OPENSUSE
- WEBLATE_SOCIAL_AUTH_UBUNTU
- WEBLATE_SOCIAL_AUTH_SLACK_KEY
在第一次启动容器时自动产生自签名的 SAML 密钥。在您想要使用自己的密钥的情况下,将证书和私钥放置在 /app/data/ssl/saml.crt
和 :file:`/app/data/ssl/saml.key`中。
- WEBLATE_SAML_IDP_ENTITY_ID
- WEBLATE_SAML_IDP_URL
- WEBLATE_NO_EMAIL_AUTH
当设置为任何值时禁止电子邮箱身份认证。
PostgreSQL 数据库设置
数据库由 docker-compose.yml
建立,所以这些设置影响 Weblate 和 PostgreSQL 容器。
- POSTGRES_PASSWORD
PostgreSQL 密码。
- POSTGRES_PASSWORD_FILE
Path to the file containing the PostgreSQL password. Use as an alternative to POSTGRES_PASSWORD.
- POSTGRES_USER
PostgreSQL 用户名。
- POSTGRES_DATABASE
PostgreSQL 数据库名。
- POSTGRES_HOST
PostgreSQL 服务器主机名成或 IP 地址。默认为
database
。
- POSTGRES_PORT
PostgreSQL 服务器端口。默认为无(使用默认值)。
- POSTGRES_SSL_MODE
配置 PostgreSQL 如何处理 SSL 连接到服务器,可能的选项请参见 SSL Mode Descriptions
- POSTGRES_ALTER_ROLE
在迁移过程中配置要改变的角色名称,请参见 配置 Weblate 来使用 PostgreSQL。
- POSTGRES_CONN_MAX_AGE
4.8.1 新版功能.
The lifetime of a database connection, as an integer of seconds. Use 0 to close database connections at the end of each request (this is the default behavior).
Enabling connection persistence will typically, cause more open connection to the database. Please adjust your database configuration prior enabling.
配置的例子:
environment: POSTGRES_CONN_MAX_AGE: 3600
参见
- POSTGRES_DISABLE_SERVER_SIDE_CURSORS
4.9.1 新版功能.
Disable server side cursors in the database. This is necessary in some pgbouncer setups.
配置的例子:
environment: POSTGRES_DISABLE_SERVER_SIDE_CURSORS: 1
数据库备份设置
参见
- WEBLATE_DATABASE_BACKUP
使用
DATABASE_BACKUP
配置每日数据库转储。默认为plain
。
缓存服务器设置
Weblate 强烈推荐使用 Redis,在 Docker 中运行 Weblate 时您必须提供 Redis 实例。
参见
- REDIS_HOST
Redis 服务器主机名称或 IP 地址。默认为
cache
。
- REDIS_PORT
Redis 服务器端口。默认为
6379
。
- REDIS_DB
Redis 数据库编号,默认为
1
。
- REDIS_PASSWORD
Redis 服务器密码,默认不使用。
- REDIS_TLS
允许使用 SSL 进行 Redis 连接。
- REDIS_VERIFY_SSL
可以用于禁止 Redis 连接的 SSL 身份认证。
电子邮件服务器设置
要使外发电子邮件正常工作,您需要提供一个邮件服务器。
TLS 配置例子:
environment:
WEBLATE_EMAIL_HOST: smtp.example.com
WEBLATE_EMAIL_HOST_USER: user
WEBLATE_EMAIL_HOST_PASSWORD: pass
SSL 配置的示例:
environment:
WEBLATE_EMAIL_HOST: smtp.example.com
WEBLATE_EMAIL_PORT: 465
WEBLATE_EMAIL_HOST_USER: user
WEBLATE_EMAIL_HOST_PASSWORD: pass
WEBLATE_EMAIL_USE_TLS: 0
WEBLATE_EMAIL_USE_SSL: 1
参见
- WEBLATE_EMAIL_HOST
邮件服务器主机名或 IP 地址。
- WEBLATE_EMAIL_PORT
邮件服务器端口,默认为 25。
参见
- WEBLATE_EMAIL_HOST_USER
电子邮件身份验证用户。
- WEBLATE_EMAIL_HOST_PASSWORD
电子邮件验证密码。
- WEBLATE_EMAIL_HOST_PASSWORD_FILE
到包含电子邮件验证密码的文件的路径。
- WEBLATE_EMAIL_USE_SSL
与 SMTP 服务器通信时是否使用隐式 TLS(安全)连接。在大多数电子邮件文档中,这种 TLS 连接类型称为 SSL。通常在端口 465 上使用。如果遇到问题,请参阅显式 TLS 设置
WEBLATE_EMAIL_USE_TLS
。
- WEBLATE_EMAIL_USE_TLS
与 SMTP 服务器通讯时是否使用 TLS(安全)连接。这用于显式 TLS 连接,通常在端口 587 或 25 上。如果您遇到挂起的连接,请参见隐式 TLS 设置
WEBLATE_EMAIL_USE_SSL
。
- WEBLATE_EMAIL_BACKEND
将 Django 后端配置为用于发送电子邮件。
- WEBLATE_AUTO_UPDATE
配置 Weblate 是否更新代码库以及如何更新。
参见
注解
This is a Boolean setting (use
"true"
or"false"
).
站点集成
- WEBLATE_GET_HELP_URL
配置
GET_HELP_URL
.
- WEBLATE_STATUS_URL
配置
STATUS_URL
.
- WEBLATE_LEGAL_URL
配置: setting:LEGAL_URL.
- WEBLATE_PRIVACY_URL
配置
PRIVACY_URL
.
错误报告
推荐从安装中系统地收集错误,请参见 收集错误报告。
要启用对 Rollbar 的支持,请进行以下设置:
- ROLLBAR_KEY
您的 Rollbar 发布服务器访问令牌。
- ROLLBAR_ENVIRONMENT
您的 Rollbar 环境,默认为
production
。
要启用对 Sentry 的支持,请进行以下设置:
- SENTRY_DSN
您的 Sentry DSN。
- SENTRY_ENVIRONMENT
您的 Sentry 环境(可选)。
语言本地化内容分发网络
- WEBLATE_LOCALIZE_CDN_URL
- WEBLATE_LOCALIZE_CDN_PATH
4.2.1 新版功能.
:ref:`addon-weblate.cdn.cdnjs`的配置。
WEBLATE_LOCALIZE_CDN_PATH
是容器内的路径。它应该存储在持久卷上,而不能存储在瞬态存储器中。一种可能性是存储在 Weblate 数据目录中:
environment: WEBLATE_LOCALIZE_CDN_URL: https://cdn.example.com/ WEBLATE_LOCALIZE_CDN_PATH: /app/data/l10n-cdn
注解
您负责设置Weblate生成的文件的服务,它只在配置的位置存储文件。
更改启用的 app、检查、插件或自动修复
3.8-5 新版功能.
可以通过后面的变量来调整允许的检查、插件或自动修复的内建配置:
- WEBLATE_ADD_APPS
- WEBLATE_REMOVE_APPS
- WEBLATE_ADD_CHECK
- WEBLATE_REMOVE_CHECK
- WEBLATE_ADD_AUTOFIX
- WEBLATE_REMOVE_AUTOFIX
- WEBLATE_ADD_ADDONS
- WEBLATE_REMOVE_ADDONS
示例:
environment:
WEBLATE_REMOVE_AUTOFIX: weblate.trans.autofixes.whitespace.SameBookendingWhitespace
WEBLATE_ADD_ADDONS: customize.addons.MyAddon,customize.addons.OtherAddon
容器设置
- WEBLATE_WORKERS
4.6.1 新版功能.
Base number of worker processes running in the container. When not set it is determined automatically on container startup based on number of CPU cores available.
It is used to determine
CELERY_MAIN_OPTIONS
,CELERY_NOTIFY_OPTIONS
,CELERY_MEMORY_OPTIONS
,CELERY_TRANSLATE_OPTIONS
,CELERY_BACKUP_OPTIONS
,CELERY_BEAT_OPTIONS
, andWEB_WORKERS
. You can use these settings to fine-tune.
- CELERY_MAIN_OPTIONS
- CELERY_NOTIFY_OPTIONS
- CELERY_MEMORY_OPTIONS
- CELERY_TRANSLATE_OPTIONS
- CELERY_BACKUP_OPTIONS
- CELERY_BEAT_OPTIONS
这些变量允许您调整 Celery worker 选项。它可以用于调整并发性(
--concurrency 16
),或使用不同的池实现(--pool=gevent
)。By default, the number of concurrent workers is based on
WEBLATE_WORKERS
.示例:
environment: CELERY_MAIN_OPTIONS: --concurrency 16
- WEB_WORKERS
配置应该执行多少个 uWSGI workers 。
It defaults to
WEBLATE_WORKERS
.示例:
environment: WEB_WORKERS: 32
- WEBLATE_SERVICE
定义应在容器内执行哪些服务,使用对象 横向扩展。
定义了以下服务:
celery-beat
Celery task scheduler, only one instance should be running. This container is also responsible for the database structure migrations and it should be started prior others.
celery-backup
Celery worker for backups, only one instance should be running.
celery-celery
Generic Celery worker.
celery-memory
翻译记忆库 Celery worker。
celery-notify
通知 Celery worker。
celery-translate
自动翻译 Celery worker。
web
Web 服务器。
Docker 容器卷
Weblate 容器导出了两个卷 (数据和缓存)。其他服务容器(PostgreSQL 或 Redis)也具有其数据卷,但本文档未涵盖这些数据卷。
数据卷用于存储 Weblate 持久数据(例如克隆的仓库)或自定义 Weblate 安装。
Docker 卷在主机系统上的位置取决于您的 Docker 配置,但通常存储在 /var/lib/docker/volumes/weblate-docker_weblate-data/_data/
中。(该路径由你的 docker-compose 目录的名称、容器和卷的名称组成)。在容器中,它挂载为 /app/data
。
The cache volume is mounted as /app/cache
and is used to store static
files. Its content is recreated on container startup and the volume can be
mounted using ephemeral filesystem such as tmpfs.
When creating the volumes manually, the directories should be owned by UID 1000 as that is user used inside the container.
参见
进一步的配置定制
您可以在数据卷中进一步自定义 Weblate 安装,请参阅 Docker 容器卷。
定制配置文件
你还可以覆盖 /app/data/settings-override.py
中的配置 (见 Docker 容器卷)。这是在所有环境设置加载之后,在内置设置末尾执行的,你可以调整或覆盖它们。
替换标志和其它静态文件
3.8-5 新版功能.
Weblate 附带的静态文件可以通过放置到 /app/data/python/customize/static
中来覆盖(请参阅 Docker 容器卷)。例如,创建 /app/data/python/customize/static/favicon.ico
将替换 favicon。
提示
在容器启动时,这些文件被复制到相应的位置,因此需要在更改卷的内容后重新启动 Weblate 。
或者,您也可以包括自己的模块(请参阅 定制 Weblate),并将其作为单独的卷添加到 Docker 容器中,例如:
weblate:
volumes:
- weblate-data:/app/data
- ./weblate_customization/weblate_customization:/app/data/python/weblate_customization
environment:
WEBLATE_ADD_APPS: weblate_customization
添加自己的 Python 模块
3.8-5 新版功能.
您可以将自己的 Python 模块放置在 /app/data/python/
中(请参阅 Docker 容器卷),然后可以由 Weblate 加载它们,很可能是使用 定制配置文件。
参见
在 Debian 和 Ubantu 上安装
硬件要求
Weblate 应该可以在任何现代硬件上正常运行,以下是在单个主机(Weblate ,数据库和 Web 服务器)上运行 Weblate 所需的最低配置:
2 GB 的内存
2 个 CPU 核心
1 GB 的存储空间
内存越多越好——用于所有级别的缓存(文件系统,数据库和 Weblate )。
许多并发用户会增加所需的 CPU 内核数量。对于数百个翻译组件,推荐至少有 4 GB 的内存。
典型的数据库存储用量大约为每 1 百万单词 300 MB。克隆仓库所需的存储空间会变化,但 Weblate 试图通过浅克隆将其大小最小化。
注解
根据 Weblate 中管理的翻译大小,安装 Weblate 的实际要求差异很大。
安装
系统要求
安装构建 Python 模块所需的依赖项(请参见 软件要求):
apt install \
libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libyaml-dev \
libcairo-dev gir1.2-pango-1.0 libgirepository1.0-dev libacl1-dev libssl-dev \
build-essential python3-gdbm python3-dev python3-pip python3-virtualenv virtualenv git
根据您打算使用的功能来安装所需的可选依赖项(参见 可选依赖项):
apt install tesseract-ocr libtesseract-dev libleptonica-dev
可选地安装生产服务器运行所需要的软件,参见 运行服务器 、 Weblate 的数据库设置 、 使用 Celery 的后台任务 。根据于您的安装所占的空间,您会想要在特定的服务器上运行这些组件。
本地安装的使用说明:
# Web server option 1: NGINX and uWSGI
apt install nginx uwsgi uwsgi-plugin-python3
# Web server option 2: Apache with ``mod_wsgi``
apt install apache2 libapache2-mod-wsgi-py3
# Caching backend: Redis
apt install redis-server
# Database server: PostgreSQL
apt install postgresql postgresql-contrib
# SMTP server
apt install exim4
Python 模块
提示
我们使用 virtualenv 将 Weblate 安装在一个与您的系统分离的环境中。如果您不熟悉它,查阅 virtualenv User Guide。
为 Weblate 新建 virtualenv:
virtualenv --python=python3 ~/weblate-env
为 Weblate 激活 virtualevn :
. ~/weblate-env/bin/activate
安装包含所有可选依赖项的 Weblate:
pip install "Weblate[all]"
Please check 可选依赖项 for fine-tuning of optional dependencies.
配置 Weblate
注解
后面的步骤假定 Weblate 使用的 virtualevn 已经激活(可以通过 . ~/weblate-env/bin/activate
来实现)。如果不是这种情况,您必须指定 到 weblate 命令的完全路径为 ~/weblate-env/bin/weblate
。
将文件
~/weblate-env/lib/python3.7/site-packages/weblate/settings_example.py
复制为~/weblate-env/lib/python3.7/site-packages/weblate/settings.py
。将新的
settings.py
文件中的值调整为您所需要的。您至少需要提供数据库凭据和Django密钥,但在生产安装中需要做更多的更改,参见: 调整配置 。为 Weblate 新建数据库及其结构(例子中的设置使用 PostgreSQL ,已经准备好的生产设置请查看 Weblate 的数据库设置 ):
weblate migrate
新建管理员用户账户,并将输出的密码复制到剪贴板,同时将它存储供以后使用:
weblate createadmin
收集 Web 服务器用的静态文件 (请参见 运行服务器 和 为静态文件提供服务 ):
weblate collectstatic
压缩 JavaScript 和 CSS 文件(可选步骤,请参见 压缩客户资产 ):
weblate compress
启动 Celery workers 。当用于开发目的是不需要这步,但仍然强烈推荐。更多信息请参见 使用 Celery 的后台任务 :
~/weblate-env/lib/python3.7/site-packages/weblate/examples/celery start
启动开发服务器(生产设置请参见 运行服务器 ):
weblate runserver
安装后
配置,您的 Weblate 服务器现在运行了,您可以使用它来启动。
您可以在
http://localhost:8000/
访问 Weblate 。使用安装时得到的管理管理员证明来登录,或注册新用户。
现在,您可以在 Weblate virtualenv 活动时使用 weblate 命令来运行 Weblate 命令。
您可以使用 Ctrl+C 来停止测试的服务器。
在
/manage/performance/
URL (参见 管理界面)上或使用 weblate check --deploy 来复查您安装的潜在问题,请参见 生产设置。
添加翻译
打开管理界面(
http://localhost:8000/create/project/
),并新建您想要翻译的项目。更多细节请参见 项目配置 。这里所有需要您指定的只是项目名称及其网站。
新建一个组件,该组件是要翻译的实际对象——它指向版本控制系统(VCS)仓库,并选择要翻译的文件。更多详细信息请参见 组件配置 。
这里的重要字段是:组件名称、版本控制系统(VCS)仓库地址和用于查找可翻译文件的掩码。Weblate 支持多种格式,包括 gettext PO 文件、Android 资源字符串、iOS 字符串属性, Java 属性或 Qt Linguist 文件,更多详细信息请参见 支持的文件格式 。
一旦完成上面的工作(根据您 VCS 仓库的大小,以及需要翻译的信息数量,这可能是个漫长的过程),您就可以开始翻译了。
在 SUSE 和 openSUSE 上安装
硬件要求
Weblate 应该可以在任何现代硬件上正常运行,以下是在单个主机(Weblate ,数据库和 Web 服务器)上运行 Weblate 所需的最低配置:
2 GB 的内存
2 个 CPU 核心
1 GB 的存储空间
内存越多越好——用于所有级别的缓存(文件系统,数据库和 Weblate )。
许多并发用户会增加所需的 CPU 内核数量。对于数百个翻译组件,推荐至少有 4 GB 的内存。
典型的数据库存储用量大约为每 1 百万单词 300 MB。克隆仓库所需的存储空间会变化,但 Weblate 试图通过浅克隆将其大小最小化。
注解
根据 Weblate 中管理的翻译大小,安装 Weblate 的实际要求差异很大。
安装
系统要求
安装构建 Python 模块所需的依赖项(请参见 软件要求):
zypper install \
libxslt-devel libxml2-devel freetype-devel libjpeg-devel zlib-devel libyaml-devel \
cairo-devel typelib-1_0-Pango-1_0 gobject-introspection-devel libacl-devel \
python3-pip python3-virtualenv python3-devel git
根据您打算使用的功能来安装所需的可选依赖项(参见 可选依赖项):
zypper install tesseract-ocr tesseract-devel leptonica-devel
可选地安装生产服务器运行所需要的软件,参见 运行服务器 、 Weblate 的数据库设置 、 使用 Celery 的后台任务 。根据于您的安装所占的空间,您会想要在特定的服务器上运行这些组件。
本地安装的使用说明:
# Web server option 1: NGINX and uWSGI
zypper install nginx uwsgi uwsgi-plugin-python3
# Web server option 2: Apache with ``mod_wsgi``
zypper install apache2 apache2-mod_wsgi
# Caching backend: Redis
zypper install redis-server
# Database server: PostgreSQL
zypper install postgresql postgresql-contrib
# SMTP server
zypper install postfix
Python 模块
提示
我们使用 virtualenv 将 Weblate 安装在一个与您的系统分离的环境中。如果您不熟悉它,查阅 virtualenv User Guide。
为 Weblate 新建 virtualenv:
virtualenv --python=python3 ~/weblate-env
为 Weblate 激活 virtualevn :
. ~/weblate-env/bin/activate
安装包含所有可选依赖项的 Weblate:
pip install "Weblate[all]"
Please check 可选依赖项 for fine-tuning of optional dependencies.
配置 Weblate
注解
后面的步骤假定 Weblate 使用的 virtualevn 已经激活(可以通过 . ~/weblate-env/bin/activate
来实现)。如果不是这种情况,您必须指定 到 weblate 命令的完全路径为 ~/weblate-env/bin/weblate
。
将文件
~/weblate-env/lib/python3.7/site-packages/weblate/settings_example.py
复制为~/weblate-env/lib/python3.7/site-packages/weblate/settings.py
。将新的
settings.py
文件中的值调整为您所需要的。您至少需要提供数据库凭据和Django密钥,但在生产安装中需要做更多的更改,参见: 调整配置 。为 Weblate 新建数据库及其结构(例子中的设置使用 PostgreSQL ,已经准备好的生产设置请查看 Weblate 的数据库设置 ):
weblate migrate
新建管理员用户账户,并将输出的密码复制到剪贴板,同时将它存储供以后使用:
weblate createadmin
收集 Web 服务器用的静态文件 (请参见 运行服务器 和 为静态文件提供服务 ):
weblate collectstatic
压缩 JavaScript 和 CSS 文件(可选步骤,请参见 压缩客户资产 ):
weblate compress
启动 Celery workers 。当用于开发目的是不需要这步,但仍然强烈推荐。更多信息请参见 使用 Celery 的后台任务 :
~/weblate-env/lib/python3.7/site-packages/weblate/examples/celery start
启动开发服务器(生产设置请参见 运行服务器 ):
weblate runserver
安装后
配置,您的 Weblate 服务器现在运行了,您可以使用它来启动。
您可以在
http://localhost:8000/
访问 Weblate 。使用安装时得到的管理管理员证明来登录,或注册新用户。
现在,您可以在 Weblate virtualenv 活动时使用 weblate 命令来运行 Weblate 命令。
您可以使用 Ctrl+C 来停止测试的服务器。
在
/manage/performance/
URL (参见 管理界面)上或使用 weblate check --deploy 来复查您安装的潜在问题,请参见 生产设置。
添加翻译
打开管理界面(
http://localhost:8000/create/project/
),并新建您想要翻译的项目。更多细节请参见 项目配置 。这里所有需要您指定的只是项目名称及其网站。
新建一个组件,该组件是要翻译的实际对象——它指向版本控制系统(VCS)仓库,并选择要翻译的文件。更多详细信息请参见 组件配置 。
这里的重要字段是:组件名称、版本控制系统(VCS)仓库地址和用于查找可翻译文件的掩码。Weblate 支持多种格式,包括 gettext PO 文件、Android 资源字符串、iOS 字符串属性, Java 属性或 Qt Linguist 文件,更多详细信息请参见 支持的文件格式 。
一旦完成上面的工作(根据您 VCS 仓库的大小,以及需要翻译的信息数量,这可能是个漫长的过程),您就可以开始翻译了。
在 Redhat、Fedora 和 CentOS 上安装
硬件要求
Weblate 应该可以在任何现代硬件上正常运行,以下是在单个主机(Weblate ,数据库和 Web 服务器)上运行 Weblate 所需的最低配置:
2 GB 的内存
2 个 CPU 核心
1 GB 的存储空间
内存越多越好——用于所有级别的缓存(文件系统,数据库和 Weblate )。
许多并发用户会增加所需的 CPU 内核数量。对于数百个翻译组件,推荐至少有 4 GB 的内存。
典型的数据库存储用量大约为每 1 百万单词 300 MB。克隆仓库所需的存储空间会变化,但 Weblate 试图通过浅克隆将其大小最小化。
注解
根据 Weblate 中管理的翻译大小,安装 Weblate 的实际要求差异很大。
安装
系统要求
安装构建 Python 模块所需的依赖项(请参见 软件要求):
dnf install \
libxslt-devel libxml2-devel freetype-devel libjpeg-devel zlib-devel libyaml-devel \
cairo-devel pango-devel gobject-introspection-devel libacl-devel \
python3-pip python3-virtualenv python3-devel git
根据您打算使用的功能来安装所需的可选依赖项(参见 可选依赖项):
dnf install tesseract-langpack-eng tesseract-devel leptonica-devel
可选地安装生产服务器运行所需要的软件,参见 运行服务器 、 Weblate 的数据库设置 、 使用 Celery 的后台任务 。根据于您的安装所占的空间,您会想要在特定的服务器上运行这些组件。
本地安装的使用说明:
# Web server option 1: NGINX and uWSGI
dnf install nginx uwsgi uwsgi-plugin-python3
# Web server option 2: Apache with ``mod_wsgi``
dnf install apache2 apache2-mod_wsgi
# Caching backend: Redis
dnf install redis
# Database server: PostgreSQL
dnf install postgresql postgresql-contrib
# SMTP server
dnf install postfix
Python 模块
提示
我们使用 virtualenv 将 Weblate 安装在一个与您的系统分离的环境中。如果您不熟悉它,查阅 virtualenv User Guide。
为 Weblate 新建 virtualenv:
virtualenv --python=python3 ~/weblate-env
为 Weblate 激活 virtualevn :
. ~/weblate-env/bin/activate
安装包含所有可选依赖项的 Weblate:
pip install "Weblate[all]"
Please check 可选依赖项 for fine-tuning of optional dependencies.
配置 Weblate
注解
后面的步骤假定 Weblate 使用的 virtualevn 已经激活(可以通过 . ~/weblate-env/bin/activate
来实现)。如果不是这种情况,您必须指定 到 weblate 命令的完全路径为 ~/weblate-env/bin/weblate
。
将文件
~/weblate-env/lib/python3.7/site-packages/weblate/settings_example.py
复制为~/weblate-env/lib/python3.7/site-packages/weblate/settings.py
。将新的
settings.py
文件中的值调整为您所需要的。您至少需要提供数据库凭据和Django密钥,但在生产安装中需要做更多的更改,参见: 调整配置 。为 Weblate 新建数据库及其结构(例子中的设置使用 PostgreSQL ,已经准备好的生产设置请查看 Weblate 的数据库设置 ):
weblate migrate
新建管理员用户账户,并将输出的密码复制到剪贴板,同时将它存储供以后使用:
weblate createadmin
收集 Web 服务器用的静态文件 (请参见 运行服务器 和 为静态文件提供服务 ):
weblate collectstatic
压缩 JavaScript 和 CSS 文件(可选步骤,请参见 压缩客户资产 ):
weblate compress
启动 Celery workers 。当用于开发目的是不需要这步,但仍然强烈推荐。更多信息请参见 使用 Celery 的后台任务 :
~/weblate-env/lib/python3.7/site-packages/weblate/examples/celery start
启动开发服务器(生产设置请参见 运行服务器 ):
weblate runserver
安装后
配置,您的 Weblate 服务器现在运行了,您可以使用它来启动。
您可以在
http://localhost:8000/
访问 Weblate 。使用安装时得到的管理管理员证明来登录,或注册新用户。
现在,您可以在 Weblate virtualenv 活动时使用 weblate 命令来运行 Weblate 命令。
您可以使用 Ctrl+C 来停止测试的服务器。
在
/manage/performance/
URL (参见 管理界面)上或使用 weblate check --deploy 来复查您安装的潜在问题,请参见 生产设置。
添加翻译
打开管理界面(
http://localhost:8000/create/project/
),并新建您想要翻译的项目。更多细节请参见 项目配置 。这里所有需要您指定的只是项目名称及其网站。
新建一个组件,该组件是要翻译的实际对象——它指向版本控制系统(VCS)仓库,并选择要翻译的文件。更多详细信息请参见 组件配置 。
这里的重要字段是:组件名称、版本控制系统(VCS)仓库地址和用于查找可翻译文件的掩码。Weblate 支持多种格式,包括 gettext PO 文件、Android 资源字符串、iOS 字符串属性, Java 属性或 Qt Linguist 文件,更多详细信息请参见 支持的文件格式 。
一旦完成上面的工作(根据您 VCS 仓库的大小,以及需要翻译的信息数量,这可能是个漫长的过程),您就可以开始翻译了。
在 macOS 上安装
硬件要求
Weblate 应该可以在任何现代硬件上正常运行,以下是在单个主机(Weblate ,数据库和 Web 服务器)上运行 Weblate 所需的最低配置:
2 GB 的内存
2 个 CPU 核心
1 GB 的存储空间
内存越多越好——用于所有级别的缓存(文件系统,数据库和 Weblate )。
许多并发用户会增加所需的 CPU 内核数量。对于数百个翻译组件,推荐至少有 4 GB 的内存。
典型的数据库存储用量大约为每 1 百万单词 300 MB。克隆仓库所需的存储空间会变化,但 Weblate 试图通过浅克隆将其大小最小化。
注解
根据 Weblate 中管理的翻译大小,安装 Weblate 的实际要求差异很大。
安装
系统要求
安装构建 Python 模块所需的依赖项(请参见 软件要求):
brew install python pango cairo gobject-introspection libffi glib libyaml
pip3 install virtualenv
确认 pip 能够找到 homebrew 提供的 libffi
版本——将在安装编译步骤中需要它。
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
根据您打算使用的功能来安装所需的可选依赖项(参见 可选依赖项):
brew install tesseract
可选地安装生产服务器运行所需要的软件,参见 运行服务器 、 Weblate 的数据库设置 、 使用 Celery 的后台任务 。根据于您的安装所占的空间,您会想要在特定的服务器上运行这些组件。
本地安装的使用说明:
# Web server option 1: NGINX and uWSGI
brew install nginx uwsgi
# Web server option 2: Apache with ``mod_wsgi``
brew install httpd
# Caching backend: Redis
brew install redis
# Database server: PostgreSQL
brew install postgresql
Python 模块
提示
我们使用 virtualenv 将 Weblate 安装在一个与您的系统分离的环境中。如果您不熟悉它,查阅 virtualenv User Guide。
为 Weblate 新建 virtualenv:
virtualenv --python=python3 ~/weblate-env
为 Weblate 激活 virtualevn :
. ~/weblate-env/bin/activate
安装包含所有可选依赖项的 Weblate:
pip install "Weblate[all]"
Please check 可选依赖项 for fine-tuning of optional dependencies.
配置 Weblate
注解
后面的步骤假定 Weblate 使用的 virtualevn 已经激活(可以通过 . ~/weblate-env/bin/activate
来实现)。如果不是这种情况,您必须指定 到 weblate 命令的完全路径为 ~/weblate-env/bin/weblate
。
将文件
~/weblate-env/lib/python3.7/site-packages/weblate/settings_example.py
复制为~/weblate-env/lib/python3.7/site-packages/weblate/settings.py
。将新的
settings.py
文件中的值调整为您所需要的。您至少需要提供数据库凭据和Django密钥,但在生产安装中需要做更多的更改,参见: 调整配置 。为 Weblate 新建数据库及其结构(例子中的设置使用 PostgreSQL ,已经准备好的生产设置请查看 Weblate 的数据库设置 ):
weblate migrate
新建管理员用户账户,并将输出的密码复制到剪贴板,同时将它存储供以后使用:
weblate createadmin
收集 Web 服务器用的静态文件 (请参见 运行服务器 和 为静态文件提供服务 ):
weblate collectstatic
压缩 JavaScript 和 CSS 文件(可选步骤,请参见 压缩客户资产 ):
weblate compress
启动 Celery workers 。当用于开发目的是不需要这步,但仍然强烈推荐。更多信息请参见 使用 Celery 的后台任务 :
~/weblate-env/lib/python3.7/site-packages/weblate/examples/celery start
启动开发服务器(生产设置请参见 运行服务器 ):
weblate runserver
安装后
配置,您的 Weblate 服务器现在运行了,您可以使用它来启动。
您可以在
http://localhost:8000/
访问 Weblate 。使用安装时得到的管理管理员证明来登录,或注册新用户。
现在,您可以在 Weblate virtualenv 活动时使用 weblate 命令来运行 Weblate 命令。
您可以使用 Ctrl+C 来停止测试的服务器。
在
/manage/performance/
URL (参见 管理界面)上或使用 weblate check --deploy 来复查您安装的潜在问题,请参见 生产设置。
添加翻译
打开管理界面(
http://localhost:8000/create/project/
),并新建您想要翻译的项目。更多细节请参见 项目配置 。这里所有需要您指定的只是项目名称及其网站。
新建一个组件,该组件是要翻译的实际对象——它指向版本控制系统(VCS)仓库,并选择要翻译的文件。更多详细信息请参见 组件配置 。
这里的重要字段是:组件名称、版本控制系统(VCS)仓库地址和用于查找可翻译文件的掩码。Weblate 支持多种格式,包括 gettext PO 文件、Android 资源字符串、iOS 字符串属性, Java 属性或 Qt Linguist 文件,更多详细信息请参见 支持的文件格式 。
一旦完成上面的工作(根据您 VCS 仓库的大小,以及需要翻译的信息数量,这可能是个漫长的过程),您就可以开始翻译了。
从源码安装
请首先按照用于您的系统的安装指示:
使用 Git 获取最新的 Weblate 源码 (或下载 tarball 包并将其解压):
git clone https://github.com/WeblateOrg/weblate.git weblate-src
另外,您可以使用发布的压缩包。您可以从我们的网站 <https://weblate.org/> 下载。这些下载是经过加密签名的,请参见 验证发布签名 。
将当前的 Weblate 代码安装到 virtualenv 中:
. ~/weblate-env/bin/activate pip install -e weblate-src
将
weblate/settings_example.py
复制为weblate/settings.py
。将新的
settings.py
文件中的值调整为您所需要的。您至少需要提供数据库凭据和Django密钥,但在生产安装中需要做更多的更改,参见: 调整配置 。新建 Weblate 使用的数据库,参见 Weblate 的数据库设置 。
建立 Django 表、静态文件和初始数据(参见 填满数据库 和 填满数据库 ):
weblate migrate weblate collectstatic weblate compress weblate compilemessages
注解
无论任何时候更新仓库时,都应该重复这一步骤。
在 OpenShift 上安装
使用OpenShift Weblate模板,您可以在几秒钟内启动并运行您的个人Weblate实例。Weblate的所有依赖项都已经包含在内。PostgreSQL被设置为默认数据库,并且使用持久化卷声明。
你可以在 <https://github.com/WeblateOrg/openshift/> 找到模板。
安装
下面的示例假设您有一个正常运作的OpenShift v3.x环境,它已经安装``oc``客户端工具。请查看OpenShift文档中的说明。
The template.yml
is suited for running all components in OpenShift.
There is also template-external-postgresql.yml
which does not start a
PostgreSQL server and allows you to configure external PostgreSQL server.
Web 控制台
从 template.yml 复制原始内容,并将它们导入你的项目,然后在 OpenShift web 控制台使用 Create
按钮来新建你的应用。web 控制台将提示你模板使用的所有参数的值。
CLI
为了将 Weblate 模板上传到你当前项目的模板库中,使用后面的命令传递 template.yml
文件:
$ oc create -f https://raw.githubusercontent.com/WeblateOrg/openshift/main/template.yml \
-n <PROJECT>
现在模板可以使用 CLI 的 web 控制台以供选择。
模板的 parameters 部分列出了你可以覆盖的参数。你可以通过使用后面的命令并指定要使用的文件通过 CLI 列出它们:
$ oc process --parameters -f https://raw.githubusercontent.com/WeblateOrg/openshift/main/template.yml
# If the template is already uploaded
$ oc process --parameters -n <PROJECT> weblate
还可以使用 CLI 来处理模板,并使用生成的配置来立即新建对象。
$ oc process -f https://raw.githubusercontent.com/WeblateOrg/openshift/main/template.yml \
-p APPLICATION_NAME=weblate \
-p WEBLATE_VERSION=4.3.1-1 \
-p WEBLATE_SITE_DOMAIN=weblate.app-openshift.example.com \
-p POSTGRESQL_IMAGE=docker-registry.default.svc:5000/openshift/postgresql:9.6 \
-p REDIS_IMAGE=docker-registry.default.svc:5000/openshift/redis:3.2 \
| oc create -f
在成功地迁移并部署特定的 WEBLATE_SITE_DOMAIN
参数后,Weblate 实例就应该可用了。
设置容器之后,您可以使用 WEBLATE_ADMIN_PASSWORD
中提供的密码以 管理员 用户身份登录,或者如果未设置密码,则使用首次启动时生成的随机密码。
要重置 管理员 密码,请在将``WEBLATE_ADMIN_PASSWORD``设置为相应的“Secret”中的新密码的情况下,重启容器。
$ oc delete all -l app=<APPLICATION_NAME>
$ oc delete configmap -l app= <APPLICATION_NAME>
$ oc delete secret -l app=<APPLICATION_NAME>
# ATTTENTION! The following command is only optional and will permanently delete all of your data.
$ oc delete pvc -l app=<APPLICATION_NAME>
$ oc delete all -l app=weblate \
&& oc delete secret -l app=weblate \
&& oc delete configmap -l app=weblate \
&& oc delete pvc -l app=weblate
配置
通过处理模板,将新建各自的 ConfigMap
,并且可以用于定制 Weblate 镜像。ConfigMap
直接作为环境变量挂载,并且在每次更改时触发新的部署。对于更多配置选项,环境变量的完整列表请参见 Docker 环境变量。
在 Kubernetes 上安装
注解
本手册寻找有 Kubernetes 经验的贡献者来详细介绍安装过程。
凭借 Kubernetes Helm 图表,您可以在几秒钟内启动并运行您的个人Weblate实例。Weblate的所有依赖项都已经包含在内。PostgreSQL被设置为默认数据库,并且使用持久化卷声明。
您可以在 <https://github.com/WeblateOrg/helm/> 找到图表,并可以在 <https://artifacthub.io/packages/helm/weblate/weblate> 显示。
安装
helm repo add weblate https://helm.weblate.org
helm install my-release weblate/weblate
配置
进一步的配置选项,请参阅 Docker 环境变量 以获取环境变量的完整列表。
根据你的设置和经验,选择一个适合你的安装方法:
使用 Docker 安装,推荐用于生产设置。
Virtualenv 安装,推荐用于生产设置:
从源码安装,推荐用于开发。
软件要求
操作系统
目前已知 Weblate 可运行在 Linux、FreeBSD 和 macOS 上。其他类 Unix 的系统也很可能支持运行。
Windows 不支持 Weblate 。但 Weblate 可能仍然可以工作,并且很乐意接受补丁。
其他服务
Weblate 为其操作使用其他服务。至少需要后面的服务运行:
PostgreSQL 数据库服务器,请参见 Weblate 的数据库设置 。
Redis 服务器,用于缓存和任务队列,请参见 使用 Celery 的后台任务 。
SMTP 服务器,用于发送电子邮件,请参见 配置电子邮件发件箱 。
Python 依赖项
Weblate 是用 Python 编写的,并且支持 Python 3.6 或更新版本。可以使用 pip 或你的分发包来安装依赖项,完整列表可在 requirements.txt
中找到。
最重要的依赖项:
- Django
- Celery
- Translate Toolkit (翻译工具包)
- translation-finder
- Python Social Auth
- Django REST 框架
可选依赖项
以下模块是某些 Weblate 功能所必需的。你可以在 requirements-optional.txt
中找到所有这些模块。
Mercurial
(可选的 Mercurial 代码库支持)phply
(可选的 PHP 字符串)tesserocr
(可选的 字符串的可视化上下文 OCR)python-akismet
(可选的 针对垃圾邮件的保护)ruamel.yaml
(可选的 YAML 文件)Zeep
(可选的 微软术语服务)aeidon
(可选的 字幕文件)fluent.syntax
(可选的 Fluent 格式)
提示
使用 pip 进行安装时,您可以在安装时直接指定所需的功能:
pip install "Weblate[PHP,Fluent]"
或者你可以安装具有所有可选功能的 Weblate:
pip install "Weblate[all]"
或者你可以安装没有任何可选功能的 Weblate:
pip install Weblate
数据库后端依赖项
Weblate 支持 PostgreSQL、MySQL 和 MariaDB,更多细节请参见 Weblate 的数据库设置 和后端文档。
其他系统要求
必须在系统上安装以下依赖项:
Git
- Pango 、 Cairo 和相关的头文件与 gir introspection 数据
https://cairographics.org/ , https://pango.gnome.org/ ,请参见 Pango 和 Cairo
git-review
(可选的 Gerrit 支持)git-svn
(可选的 Subversion 支持)tesseract
及其数据(可选的截屏 OCR)licensee
(可选,用于创建组件时检测许可证)
构建时的依赖项
为了构建一些 Python 依赖项,你可能需要安装其依赖项。这取决于你如何安装它们,因此请查阅各个包的文档。如果你使用预编译 Wheels
并使用 pip
安装或使用分发包时,则不需要那些依赖项。
Pango 和 Cairo
在 3.7 版更改.
Weblate 使用 Pango 和 Cairo 来生成位图小挂件(请参见 推广翻译 )并提供检查(请参见 管理字型 )。要正确地安装 Python 绑定,需要首先安装系统库——Cairo 和 Pango 都是需要的,而它们又需要 GLib 。所有这些都应该与开发文件和 GObject 内省数据一起安装。
验证发布签名
Weblate 的发布由发布开发者通过密码签发。当前是 Michal Čihař 。他的 PGP 密钥指纹是:
63CB 1DF1 EF12 CF2A C0EE 5A32 9C27 B313 42B7 511D
还可以从 <https://keybase.io/nijel> 获取更多身份信息。
您应该验证签名是否与您所下载的压缩包相符,这样可以确保使用的代码与发布的代码相同。您还应该验证签名的日期,以确保下载的是最新版本。
每个压缩包都带有 .asc
文件,其中包含它的 PGP 签名。将它们放在同一个文件夹中后,就可以验证签名了:
$ gpg --verify Weblate-3.5.tar.xz.asc
gpg: assuming signed data in 'Weblate-3.5.tar.xz'
gpg: Signature made Ne 3. března 2019, 16:43:15 CET
gpg: using RSA key 87E673AF83F6C3A0C344C8C3F4AA229D4D58C245
gpg: Can't check signature: public key not found
正如你所看到的,GPG抱怨它不知道公钥。此时应该执行以下步骤之一:
使用 wkd 来下载密钥:
$ gpg --auto-key-locate wkd --locate-keys michal@cihar.com
pub rsa4096 2009-06-17 [SC]
63CB1DF1EF12CF2AC0EE5A329C27B31342B7511D
uid [ultimate] Michal Čihař <michal@cihar.com>
uid [ultimate] Michal Čihař <nijel@debian.org>
uid [ultimate] [jpeg image of size 8848]
uid [ultimate] Michal Čihař (Braiins) <michal.cihar@braiins.cz>
sub rsa4096 2009-06-17 [E]
sub rsa4096 2015-09-09 [S]
从 Michal 的服务器 下载密钥环,然后将其导入:
$ gpg --import wmxth3chu9jfxdxywj1skpmhsj311mzm
从一个密钥服务器下载并导入密钥:
$ gpg --keyserver hkp://pgp.mit.edu --recv-keys 87E673AF83F6C3A0C344C8C3F4AA229D4D58C245
gpg: key 9C27B31342B7511D: "Michal Čihař <michal@cihar.com>" imported
gpg: Total number processed: 1
gpg: unchanged: 1
这会将情况改善一点——在这点上可以验证给定密钥的签名是正确的,但仍然不能相信密钥中使用的名称:
$ gpg --verify Weblate-3.5.tar.xz.asc
gpg: assuming signed data in 'Weblate-3.5.tar.xz'
gpg: Signature made Ne 3. března 2019, 16:43:15 CET
gpg: using RSA key 87E673AF83F6C3A0C344C8C3F4AA229D4D58C245
gpg: Good signature from "Michal Čihař <michal@cihar.com>" [ultimate]
gpg: aka "Michal Čihař <nijel@debian.org>" [ultimate]
gpg: aka "[jpeg image of size 8848]" [ultimate]
gpg: aka "Michal Čihař (Braiins) <michal.cihar@braiins.cz>" [ultimate]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 63CB 1DF1 EF12 CF2A C0EE 5A32 9C27 B313 42B7 511D
这里的问题是,任何人都可以使用这个名称发放密钥。您需要确保密钥确实是为提到的人所拥有。GNU 隐私手册在 验证公共密钥环上的其他密钥 一章中介绍了这个主题。最可靠的方法是与开发者面对面交换密钥指纹,不过你也可以依靠信任网络。这样您就可以信任通过与开发者见过面的其他人的签名传递的密钥。
一旦信任了密钥,警告就不会发生:
$ gpg --verify Weblate-3.5.tar.xz.asc
gpg: assuming signed data in 'Weblate-3.5.tar.xz'
gpg: Signature made Sun Mar 3 16:43:15 2019 CET
gpg: using RSA key 87E673AF83F6C3A0C344C8C3F4AA229D4D58C245
gpg: Good signature from "Michal Čihař <michal@cihar.com>" [ultimate]
gpg: aka "Michal Čihař <nijel@debian.org>" [ultimate]
gpg: aka "[jpeg image of size 8848]" [ultimate]
gpg: aka "Michal Čihař (Braiins) <michal.cihar@braiins.cz>" [ultimate]
如果签名无效(压缩包已被更改),那么无论密钥是否可信,都会得到明显的错误:
$ gpg --verify Weblate-3.5.tar.xz.asc
gpg: Signature made Sun Mar 3 16:43:15 2019 CET
gpg: using RSA key 87E673AF83F6C3A0C344C8C3F4AA229D4D58C245
gpg: BAD signature from "Michal Čihař <michal@cihar.com>" [ultimate]
文件系统权限
Weblate 进程需要能够读写它保存数据的目录 — DATA_DIR
。该目录下的所有文件都应该由运行所有 Weblate 进程的用户拥有和可写入(通常是 WSGI 和 Celery,请参见 运行服务器 and 使用 Celery 的后台任务)。
默认的配置放置在 Weblate 源的相同树下,然而你会想要将这些移动到更好的位置,如: /var/lib/weblate
。
Weblate 试图自动建立这些文件夹,但当没有权限去执行时会失败。
当运行 管理命令 时应该小心,它们应该由 Weblate 自己运行的相同用户来运行,否则一些文件的权限会是错误的。
在 Docker 容器中, /app/data
卷中的所有文件必须由容器内的 Weblate 用户(UID 1000)所有。
参见
Weblate 的数据库设置
推荐使用 PostgreSQL 数据库服务器来运行 Weblate。
PostgreSQL
PostgreSQL 通常是基于 Django 的网站的最好选择。它是实现 Django 数据库层而使用的参考数据库。
注解
Weblate 使用三字母的扩展名,在某些情况下需要单独安装。查找 postgresql-contrib
或类似命名的包。
创建 PostgreSQL 数据库
在另一个单独的数据库中运行 Weblate ,并将用户账户分开通常是个好方法:
# If PostgreSQL was not installed before, set the main password
sudo -u postgres psql postgres -c "\password postgres"
# Create a database user called "weblate"
sudo -u postgres createuser --superuser --pwprompt weblate
# Create the database "weblate" owned by "weblate"
sudo -u postgres createdb -E UTF8 -O weblate weblate
提示
如果不想 Weblate 在 PostgreSQL 中使用超级用户,可以省略掉。在模式中必须作为 PostgreSQL 超级用户,来手动执行一些迁移步骤的情况下, Weblate 将使用:
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA weblate;
配置 Weblate 来使用 PostgreSQL
PostgreSQL 的 settings.py
片段:
DATABASES = {
"default": {
# Database engine
"ENGINE": "django.db.backends.postgresql",
# Database name
"NAME": "weblate",
# Database user
"USER": "weblate",
# Name of role to alter to set parameters in PostgreSQL,
# use in case role name is different than user used for authentication.
# "ALTER_ROLE": "weblate",
# Database password
"PASSWORD": "password",
# Set to empty string for localhost
"HOST": "database.example.com",
# Set to empty string for default
"PORT": "",
}
}
数据库的合并执行了Weblate 使用的 ALTER ROLE 数据库角色。在多数情况下,角色的名称与用户名匹配。在更富在的设置中,角色的名称与用户名不同,而在数据库合并过程中会得到不存在的角色的错误信息(psycopg2.errors.UndefinedObject: role "weblate@hostname" does not exist
,角色“weblate@hostname”不存在)。已知这会在 PostgreSQL 的 Azure 数据库时发生,但并不仅限于这种环境。请将 ALTER_ROLE
设置为数据库合并过程中 Weblate 应该更改的角色的名称。
MySQL 和 MariaDB
提示
一些 Weblate 功能使用 PostgreSQL 会表现得更好。这包括搜索与翻译记忆库,它们都利用了数据库中的全文特性,而且 PostgreSQL 的实现更胜一筹。
Weblate 还可以使用 MySQL 或 MariaDB ,使用与两个数据库相关的 Django 而导致的警告,请参见 MySQL 注意事项 和 MariaDB 注意事项 。由于这些限制,我们建议对新安装使用 PostgreSQL。
Weblate 需要至少 5.7.8 版的或至少 10.2.7 版的 MariaDB。
推荐 Weblate 使用后面的设置:
使用
utf8mb4
字符集来允许表示更高的 Unicode 平面(例如 emojis 表情符号)。用
innodb_large_prefix
配置服务器,以允许在文本字段上有更长的索引。设置隔离级别为
READ COMMITTED
。SQL 模式应该设置为
STRICT_TRANS_TABLES
。
MySQL 8.x, MariaDB 10.5.x or newer have reasonable default configuration so that no server tweaking should be necessary and all what is needed can be configured on the client side.
下面是用于 8GB 内存服务器的 /etc/my.cnf.d/server.cnf
的例子。这些设置应该足以用于多数安装。MySQL 和 MariaDB 具有来提高服务器性能的可调整部分,除非计划有大量并发用户访问系统,否则这些可调整部分被认为是不必要的。这些细节请查看各厂商的文档。
在运行您的 Weblate 前设置好 innodb_file_per_table
设置并重启 MySQL/MariaDB,这对减少安装时的问题绝对重要。
[mysqld]
character-set-server = utf8mb4
character-set-client = utf8mb4
collation-server = utf8mb4_unicode_ci
datadir=/var/lib/mysql
log-error=/var/log/mariadb/mariadb.log
innodb_large_prefix=1
innodb_file_format=Barracuda
innodb_file_per_table=1
innodb_buffer_pool_size=2G
sql_mode=STRICT_TRANS_TABLES
提示
如遇 #1071 - Specified key was too long; max key length is 767 bytes
错误, 请更新你的配置以包含上方的 innodb
设置并重新启动你的安装。
提示
在得到错误信息 #2006 - MySQL server has gone away
的形况下,配置 CONN_MAX_AGE
可能会有帮助。
配置 Weblate 来使用 MySQL/MariaDB
MySQL 和 MariaDB 的 settings.py
片段:
DATABASES = {
"default": {
# Database engine
"ENGINE": "django.db.backends.mysql",
# Database name
"NAME": "weblate",
# Database user
"USER": "weblate",
# Database password
"PASSWORD": "password",
# Set to empty string for localhost
"HOST": "127.0.0.1",
# Set to empty string for default
"PORT": "3306",
# In case you wish to use additional
# connection options
"OPTIONS": {},
}
}
开始安装前还应该在 MySQL 或 MariaDB 中创建 weblate
用户账户。使用下面的命令来实现:
GRANT ALL ON weblate.* to 'weblate'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
其他配置
配置电子邮件发件箱
Weblate 在各种情况下会发出电子邮件——用于激活账户,以及用户配置的各种通知。对于这些需要访问 SMTP 服务器。
邮件服务器使用这些设置进行配置: EMAIL_HOST
, EMAIL_HOST_PASSWORD
, EMAIL_USE_TLS
, EMAIL_USE_SSL
, EMAIL_HOST_USER
and EMAIL_PORT
。从名称就可以大概知道它们的含义,但是你可以在Django 文档中找到更多信息。
提示
在得到有关不支持的认证的情况下(例如 SMTP AUTH extension not supported by server
),这最可能因为使用不安全的链接并且服务器拒绝以这种方式认证而导致。在这种情况下尝试启动 EMAIL_USE_TLS
。
在反向代理后面运行
Weblate 的几个特性依赖于能够得到客户端 IP 地址。这包括 频次限制 、 针对垃圾邮件的保护 或 审计日志。
在默认设置中, Weblate 从 WSGI 句柄设置的 REMOTE_ADDR
中解析 IP 地址。
在运行反向代理的情况下,这个字段很可能包含其地址。需要配置 Weblate 来信任附加的 HTTP 标头,并从中解析 IP 地址。这不能默认允许,因为在不使用反向代理的安装时,这会允许 IP 地址欺骗。允许 IP_BEHIND_REVERSE_PROXY
对多数常见设置就足够了,但你还必须调整 IP_PROXY_HEADER
和 IP_PROXY_OFFSET
。
HTTP 代理
Weblate 执行版本控制系统(VCS)命令,这些命令接受来自环境的代理配置。推荐在 settings.py
中定义代理设置:
import os
os.environ["http_proxy"] = "http://proxy.example.com:8080"
os.environ["HTTPS_PROXY"] = "http://proxy.example.com:8080"
参见
调整配置
参见
将 weblate/settings_example.py
复制到 weblate/settings.py
,并且调整它与你的设置匹配。你可能想要调整后面的选项:
ADMINS
ALLOWED_HOSTS
需要设置这个,来列出你的网站支持服务的主机。例如:
ALLOWED_HOSTS = ["demo.weblate.org"]另外可以包括通配符:
ALLOWED_HOSTS = ["*"]
SESSION_ENGINE
配置如何存储会话。在保持默认的数据库后端引擎的情况下,应该安排 weblate clearsessions 从数据库中删除旧的会话。
如果使用 Redis 作为缓存(请参见 允许缓存 ),推荐也使用它作为会话:
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
DATABASES
连接到数据库服务器,请查阅 Django 的文档了解详情。
参见
DEBUG
DEFAULT_FROM_EMAIL
用于发送电子邮件的电子邮件发件人地址,例如注册电子邮箱。
SECRET_KEY
Django 使用的密钥,用于在 cookie 中登录一些信息,更多信息请参见 Django 密钥 。
参见
SERVER_EMAIL
用作向管理员发送电子邮件的发送者地址的邮箱,例如通知失败的合并。
参见
填满数据库
在配置准备好之后,可以运行 weblate migrate
来建立数据库结构。现在你将能够使用管理界面建立翻译项目。
在想要非交互式地运行安装的情况下,可以使用 weblate migrate --noinput
,然后使用 createadmin
命令来建立管理用户。
完成后,你还应该在管理界面查看 Performance report,它会提示你站点上可能存在的非最佳配置。
生产设置
对于生产设置,你应该进行以下部分中所述的调整。最关键的设置将触发警告:如果以超级用户身份登录,则会在顶部栏中显示一个叹号:

同样也推荐查看由 Django 触发的检查(尽管可能不需要修复所有的检查):
weblate check --deploy
您也可以从 管理界面 查看完全一样的检查清单。
参见
禁止调试模式
禁止 Django 的调试模式( DEBUG
):
DEBUG = False
在调试模式打开时,Django 存储所有执行的查询,并将错误的回溯显示给用户,这在生产设置中是不需要的。
参见
是当地配置管理设置
将正确的管理地址设置到 ADMINS
设置中,来确定服务器出现一些故障时谁接收电子邮件,例如:
ADMINS = (("Your Name", "your_email@example.com"),)
参见
设置正确的网站域名
在管理界面调整网站名称和域名,否则 RSS 中的链接或注册电子邮件地址将不工作。这使用 SITE_DOMAIN
来配置,它应该包含网站域名。
在 4.2 版更改: 在 4.2 版本之前,替代使用了 Django 网站框架,请参见 “站点”框架 。
正确配置 HTTPS
强烈推荐使用加密的 HTTPS 协议 运行 Weblate。将其允许后,可以在设置中设置 ENABLE_HTTPS
:
ENABLE_HTTPS = True
提示
你还会想要新建 HSTS,更多细节请参见 SSL/HTTPS 。
参见
适当设置 SECURE_HSTS_SECONDS
如果你的网站基于 SSL 上提供服务,那么必须考虑 settings.py
中 SECURE_HSTS_SECONDS
的设置值,来允许 HTTP Strict Transport Security ( HTTP 脚本传输安全)。默认设置为 0 ,如下所示。
SECURE_HSTS_SECONDS = 0
如果设置为非 0 整数,那么在所有还不曾具有它的响应时, django.middleware.security.SecurityMiddleware
设置 HTTP 严格传输安全 标头。
警告
不正确的设置这项会导致你的网站不可逆地(在一段时间内)崩溃。请首先阅读 HTTP 严格传输安全 文档。
使用强力的数据库引擎
请使用 PostgreSQL 作为生产环境,更多信息请参见 Weblate 的数据库设置 。
Use adjacent location for running the database server, otherwise the networking performance or reliability might ruin your Weblate experience.
Check the database server performance or tweak its configuration, for example using PGTune.
允许缓存
如果可能,通过调整 CACHES
配置变量来使用来自 Django 的 Redis ,例如:
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/0",
# If redis is running on same host as Weblate, you might
# want to use unix sockets instead:
# 'LOCATION': 'unix:///var/run/redis/redis.sock?db=0',
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"PARSER_CLASS": "redis.connection.HiredisParser",
},
}
}
提示
在为缓存更改 Redis 设置的情况下,也会需要为 Celery 来调整,请参见 使用 Celery 的后台任务。
参见
头像缓存
除了 Django 的缓存, Weblate 还执行头像缓存。推荐使用单独的、文件后端缓存来用于这个目的:
CACHES = {
"default": {
# Default caching backend setup, see above
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "unix:///var/run/redis/redis.sock?db=0",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"PARSER_CLASS": "redis.connection.HiredisParser",
},
},
"avatar": {
"BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
"LOCATION": os.path.join(DATA_DIR, "avatar-cache"),
"TIMEOUT": 604800,
"OPTIONS": {
"MAX_ENTRIES": 1000,
},
},
}
配置电子邮件发送的设置
Weblate 需要在几种情况下发送电子邮件,这些电子邮件应具有正确的发送者地址,请配置:setting:SERVER_EMAIL 和 DEFAULT_FROM_EMAIL
,与你的环境匹配,例如:
SERVER_EMAIL = "admin@example.org"
DEFAULT_FROM_EMAIL = "weblate@example.org"
注解
为了禁止 Weblate 发送电子邮件,将 EMAIL_BACKEND
设置为 django.core.mail.backends.dummy.EmailBackend
。
这将禁止 所有 电子邮件的投递,包括注册或密码重置电子邮件。
允许主机设置
Django 需要 ALLOWED_HOSTS
保存你的网站允许服务的域名列表,将其保持空置会屏蔽任何请求。
在没有配置来匹配 HTTP 服务器的情况下,会得到错误信息,如 Invalid HTTP_HOST header: '1.1.1.1'. You may need to add '1.1.1.1' to ALLOWED_HOSTS.
提示
在 Docker 容器上,这可以使用,为 WEBLATE_ALLOWED_HOSTS
。
Django 密钥
SECRET_KEY
设置由 Django 使用来进行 cookies 签名,应该真正产生自己的值,而不是使用来自举例的设置的值。
可以使用与 Weblate 一起上市的 weblate/examples/generate-secret-key
, 来产生新的密钥。
参见
Home 目录
在 2.1 版更改: 这不再需要了, Weblate现在将所有数据存储在 DATA_DIR
。
运行 Weblate 的用户主目录应该存在,并可由该用户写入。如果你想使用 SSH 访问私有仓库,这一点尤其重要,但 Git 可能也需要访问这个目录(取决于你使用的 Git 版本)。
可以在 settings.py
中更改 Weblate 使用的目录,例如,将其设置到 Weblate 树下面的 configuration
目录中:
os.environ["HOME"] = os.path.join(BASE_DIR, "configuration")
注解
在 Linux 和其他类似 UNIX 系统上,到用户主目录的路径在 /etc/passwd
中确定。很多发行版默认用户使用不可写入目录来提供 Web 内容服务(如 apache
、 www-data
或 wwwrun
)。
模板加载
对于 Django 推荐使用缓存模板的加载程序。它将已分析的模板装入,并避免对每个单独的请求多进行分析。可以使用后面的模板来配置它(这里 loaders
设置很重要):
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
os.path.join(BASE_DIR, "templates"),
],
"OPTIONS": {
"context_processors": [
"django.contrib.auth.context_processors.auth",
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.request",
"django.template.context_processors.csrf",
"django.contrib.messages.context_processors.messages",
"weblate.trans.context_processors.weblate_context",
],
"loaders": [
(
"django.template.loaders.cached.Loader",
[
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
],
),
],
},
},
]
运行维护任务
为了优化性能,在后台运行一些维护任务是个好方法。现在这由 使用 Celery 的后台任务 自动进行,并且包括后面的任务:
配置健康性的检查(每小时)。
提交待定的更改(每小时),请参见 惰性提交 和
commit_pending
。更新组件警报(每天)。
更新远程分支(每晚),请参见
AUTO_UPDATE
。翻译记忆库备份到 JSON (每天),请参见
dump_memory
。全文本和数据库维护任务(每天和每周任务),请参见
cleanuptrans
。
在 3.2 版更改: 从 3.2 版本开始,执行这些任务的默认方式是使用 Celery ,并且 Weblate 已经具有一些适当的配置,请参见 使用 Celery 的后台任务 。
系统的地区与编码
系统的地区应该设置为兼容 UTF-8 的。在多数 Linux 发行版中这是默认设置。在你的系统不能兼容的情况下,请将地区更改为 UTF-8 变体。
例如通过编辑 /etc/default/locale
并设置 LANG="C.UTF-8"
。
某些情况下,各个服务具有不同的区域设置配置。这在不同发行版和 web 服务器之间是不同的,所以请查阅你的 web 服务器包的文档。
Apache on Ubuntu uses /etc/apache2/envvars
:
export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
Apache on CentOS uses /etc/sysconfig/httpd
(or
/opt/rh/httpd24/root/etc/sysconfig/httpd
):
LANG='en_US.UTF-8'
压缩客户资产
Weblate 带有一组 JavaScript 和 CSS 文件。由于性能的原因,在将其发送到客户端前最好进行压缩。在默认配置中,这通过耗费一点经常资源而在运行中完成。在大型安装中,推荐允许离线压缩模式。这需要在配置中完成,并且必须在每次 weblate 升级时触发压缩。
配置切换很简单,通过允许 django.conf.settings.COMPRESS_OFFLINE
,并配置 django.conf.settings.COMPRESS_OFFLINE_CONTEXT
(后者已经包括在例子的配置中):
COMPRESS_OFFLINE = True
在每个部署中,您需要压缩文件来匹配当前的版本:
weblate compress
提示
官方 Docker 镜像已经允许了这个特性。
运行服务器
提示
In case you are not experienced with services described below, you might want to try 使用 Docker 安装.
需要几个服务来运行Weblate,推荐的设置包括:
数据库服务器(请参见 Weblate 的数据库设置 )
缓存服务器(请参见 允许缓存 )
用于静态文件和终结 SSL 的前端 web 服务器(请参见 为静态文件提供服务 )
用于动态内容的 WSGI 服务器(请参见 NGINX 和 uWSGI 的配置例子 )
用于执行后台任务的 Celery (请参见 使用 Celery 的后台任务 )
注解
这些服务之间由一些依赖项,例如当启动 Celery 或 uwsgi 进程时,缓存和数据库应该运行。
在多数情况下,需要在单一(虚拟)服务器上运行所有服务,但在您的安装是重载的情况下,可以将这些服务拆开。对此的唯一限制是 Celery 和 Wsgi 服务器需要访问 DATA_DIR
。
运行 web 服务器
运行 Weblate 与运行其他任何基于 Django 的程序没什么不同。 Django通常作为 uWSGI 或 fcgi 执行(请参见下面不同 web 服务器的例子)。
为了检测的目的,您可以在 Django 中使用内建的 web 服务器:
weblate runserver
警告
不要使用在生产设置中这个服务器。它还没有通过安全审查或性能检测。请参见 Django 文档中的 runserver
。
提示
Django 内建服务只通过允许 DEBUG
来为静态文件提供服务,因为它只用于开发的目的。对于生产使用,请参见 NGINX 和 uWSGI 的配置例子 、 Apache 的配置例子 Apache 和 Gunicorn 的配置例子 和 为静态文件提供服务 中的wsgi 设置。
为静态文件提供服务
在 2.4 版更改: 在 2.4 版本之前, Weblate 不能正常使用 Django 静态文件框架,并且设置更复杂。
Django 需要将其静态文件收集在一个单一文件夹中。为此,执行 weblate collectstatic --noinput
。这会将静态文件复制到 STATIC_ROOT
设置指定的文件夹中(这默认为 DATA_DIR
内的 static
文件夹)。
推荐直接从你的 web 服务器为静态文件提供服务,对于后面的路径应该使用它:
/static/
为 Weblate 的静态文件和 管理界面(由
STATIC_ROOT
定义)提供服务。/media/
用于上传用户媒体(例如截屏)。
/favicon.ico
应该重写,重写规则为
/static/favicon.ico
提供服务。
内容安全政策
默认的 Weblate 配置允许 weblate.middleware.SecurityMiddleware
中间件,它设置与 HTTP 标头相关的安全,如 Content-Security-Policy
或 X-XSS-Protection
。这些被默认新建,与 Weblate 及其配置一起工作,但这对你的环境需要定制化。
NGINX 和 uWSGI 的配置例子
为了运行生产 web 服务器,使用与 Weblate 一起安装的 wsgi 封装(在虚拟 env 的情况下,它安装为 ~/weblate-env/lib/python3.7/site-packages/weblate/wsgi.py
)。别忘了将 Python 的搜索路径同样设置为 您的虚拟 env (例如在 uWSGI 中使用 virtualenv = /home/user/weblate-env
)。
后面的配置将 Weblate 作为 NGINX web 服务器下的 uWSGI 来运行。
NGINX 的配置(还作为 weblate/examples/weblate.nginx.conf
来获得):
# This example assumes Weblate is installed in virtualenv in /home/weblate/weblate-env
# and DATA_DIR is set to /home/weblate/data, please adjust paths to match your setup.
server {
listen 80;
server_name weblate;
# Not used
root /var/www/html;
location ~ ^/favicon.ico$ {
# DATA_DIR/static/favicon.ico
alias /home/weblate/data/static/favicon.ico;
expires 30d;
}
location /static/ {
# DATA_DIR/static/
alias /home/weblate/data/static/;
expires 30d;
}
location /media/ {
# DATA_DIR/media/
alias /home/weblate/data/media/;
expires 30d;
}
location / {
include uwsgi_params;
# Needed for long running operations in admin interface
uwsgi_read_timeout 3600;
# Adjust based to uwsgi configuration:
uwsgi_pass unix:///run/uwsgi/app/weblate/socket;
# uwsgi_pass 127.0.0.1:8080;
}
}
uWSGI 的配置(还作为 weblate/examples/weblate.uwsgi.ini
来获得):
# This example assumes Weblate is installed in virtualenv in /home/weblate/weblate-env
# and DATA_DIR is set to /home/weblate/data, please adjust paths to match your setup.
[uwsgi]
plugins = python3
master = true
protocol = uwsgi
socket = 127.0.0.1:8080
wsgi-file = /home/weblate/weblate-env/lib/python3.9/site-packages/weblate/wsgi.py
# Add path to Weblate checkout if you did not install
# Weblate by pip
# python-path = /path/to/weblate
# In case you're using virtualenv uncomment this:
virtualenv = /home/weblate/weblate-env
# Needed for OAuth/OpenID
buffer-size = 8192
# Reload when consuming too much of memory
reload-on-rss = 250
# Increase number of workers for heavily loaded sites
workers = 8
# Enable threads for Sentry error submission
enable-threads = true
# Child processes do not need file descriptors
close-on-exec = true
# Avoid default 0000 umask
umask = 0022
# Run as weblate user
uid = weblate
gid = weblate
# Enable harakiri mode (kill requests after some time)
# harakiri = 3600
# harakiri-verbose = true
# Enable uWSGI stats server
# stats = :1717
# stats-http = true
# Do not log some errors caused by client disconnects
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true
Apache 的配置例子
推荐当 Weblate 使用 WSGI 时使用 prefork MPM。
后面的配置将 Weblate 作为 WSGI 来运行,您需要允许 ``mod_wsgi``(作为 weblate/examples/apache.conf
来获得):
#
# VirtualHost for Weblate
#
# This example assumes Weblate is installed in virtualenv in /home/weblate/weblate-env
# and DATA_DIR is set to /home/weblate/data, please adjust paths to match your setup.
#
<VirtualHost *:80>
ServerAdmin admin@weblate.example.org
ServerName weblate.example.org
# DATA_DIR/static/favicon.ico
Alias /favicon.ico /home/weblate/data/static/favicon.ico
# DATA_DIR/static/
Alias /static/ /home/weblate/data/static/
<Directory /home/weblate/data/static/>
Require all granted
</Directory>
# DATA_DIR/media/
Alias /media/ /home/weblate/data/media/
<Directory /home/weblate/data/media/>
Require all granted
</Directory>
# Path to your Weblate virtualenv
WSGIDaemonProcess weblate python-home=/home/weblate/weblate-env user=weblate
WSGIProcessGroup weblate
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /home/weblate/weblate-env/lib/python3.7/site-packages/weblate/wsgi.py process-group=weblate request-timeout=600
WSGIPassAuthorization On
<Directory /home/weblate/weblate-env/lib/python3.7/site-packages/weblate/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
注解
Weblate 需要 Python 3 ,所以请确认您运行 modwsgi 的 Python 3 变体。它通常作为独立的包来获得,例如 libapache2-mod-wsgi-py3
。
Apache 和 Gunicorn 的配置例子
后面的配置在 Gunicorn 和 Apache 2.4 中运行 Weblate (作为 weblate/examples/apache.gunicorn.conf
获得):
#
# VirtualHost for Weblate using gunicorn on localhost:8000
#
# This example assumes Weblate is installed in virtualenv in /home/weblate/weblate-env
# and DATA_DIR is set to /home/weblate/data, please adjust paths to match your setup.
#
<VirtualHost *:443>
ServerAdmin admin@weblate.example.org
ServerName weblate.example.org
# DATA_DIR/static/favicon.ico
Alias /favicon.ico /home/weblate/data/static/favicon.ico
# DATA_DIR/static/
Alias /static/ /home/weblate/data/static/
<Directory /home/weblate/data/static/>
Require all granted
</Directory>
# DATA_DIR/media/
Alias /media/ /home/weblate/data/media/
<Directory /home/weblate/data/media/>
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/https_cert.cert
SSLCertificateKeyFile /etc/apache2/ssl/https_key.pem
SSLProxyEngine On
ProxyPass /favicon.ico !
ProxyPass /static/ !
ProxyPass /media/ !
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
ProxyPreserveHost On
</VirtualHost>
在路径下运行 Weblate
1.3 新版功能.
推荐当 Weblate 使用 WSGI 时使用 prefork MPM。
为``/weblate`` 下的 Weblate 提供服务的 Apache 配置的例子。再次使用 mod_wsgi
(还作为 weblate/examples/apache-path.conf
获得):
#
# VirtualHost for Weblate, running under /weblate path
#
# This example assumes Weblate is installed in virtualenv in /home/weblate/weblate-env
# and DATA_DIR is set to /home/weblate/data, please adjust paths to match your setup.
#
<VirtualHost *:80>
ServerAdmin admin@weblate.example.org
ServerName weblate.example.org
# DATA_DIR/static/favicon.ico
Alias /weblate/favicon.ico /home/weblate/data/static/favicon.ico
# DATA_DIR/static/
Alias /weblate/static/ /home/weblate/data/static/
<Directory /home/weblate/data/static/>
Require all granted
</Directory>
# DATA_DIR/media/
Alias /weblate/media/ /home/weblate/data/media/
<Directory /home/weblate/data/media/>
Require all granted
</Directory>
# Path to your Weblate virtualenv
WSGIDaemonProcess weblate python-home=/home/weblate/weblate-env user=weblate
WSGIProcessGroup weblate
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias /weblate /home/weblate/weblate-env/lib/python3.7/site-packages/weblate/wsgi.py process-group=weblate request-timeout=600
WSGIPassAuthorization On
<Directory /home/weblate/weblate-env/lib/python3.7/site-packages/weblate/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
此外,您必须调整 weblate/settings.py
:
URL_PREFIX = "/weblate"
使用 Celery 的后台任务
3.2 新版功能.
Weblate uses Celery to execute regular and background tasks. You are supposed to run a Celery service that will execute these. For example, it is responsible for handling following operations (this list is not complete):
Receiving webhooks from external services (see 通知钩子).
Running regular maintenance tasks such as backups, cleanups, daily add-ons, or updates (see 备份和移动 Weblate,
BACKGROUND_TASKS
, 附加组件).正在运行 自动化翻译.
发送摘要通知。
Offloading expensive operations from the wsgi process.
提交待定更改 (参见 惰性提交)。
使用 Redis 作为后端的典型安装看上去是这样的:
CELERY_TASK_ALWAYS_EAGER = False
CELERY_BROKER_URL = "redis://localhost:6379"
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
您应该启动 Celery worker 来处理任务,并且定时任务,这可以直接在命令行完成(调试和开发时最有用):
./weblate/examples/celery start
./weblate/examples/celery stop
Executing Celery tasks in the wsgi using eager mode
注解
This will have severe performance impact on the web interface, and will break features depending on regular trigger (for example committing pending changes, digest notifications, or backups).
对于开发,你可能希望使用 eager configuration,它可以适当地处理所有任务:
CELERY_TASK_ALWAYS_EAGER = True
CELERY_BROKER_URL = "memory://"
CELERY_TASK_EAGER_PROPAGATES = True
运行 Celery 作为系统服务
您更可能想要运行 Celery 作为守护进程,这由 Daemonization 来涵盖。对于使用 systemd 的最通常的 Linux 设置,您可以使用与下面列出的 examples
文件夹一起上市的例子文件。
Systemd 单元作为 /etc/systemd/system/celery-weblate.service
放置:
[Unit]
Description=Celery Service (Weblate)
After=network.target
[Service]
Type=forking
User=weblate
Group=weblate
EnvironmentFile=/etc/default/celery-weblate
WorkingDirectory=/home/weblate
RuntimeDirectory=celery
RuntimeDirectoryPreserve=restart
LogsDirectory=celery
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \
--pidfile=${CELERYD_PID_FILE}'
ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
[Install]
WantedBy=multi-user.target
环境配置作为 /etc/default/celery-weblate
放置:
# Name of nodes to start
CELERYD_NODES="celery notify memory backup translate"
# Absolute or relative path to the 'celery' command:
CELERY_BIN="/home/weblate/weblate-env/bin/celery"
# App instance to use
# comment out this line if you don't use an app
CELERY_APP="weblate.utils"
# Extra command-line arguments to the worker,
# increase concurency if you get weblate.E019
CELERYD_OPTS="--beat:celery --queues:celery=celery --prefetch-multiplier:celery=4 \
--queues:notify=notify --prefetch-multiplier:notify=10 \
--queues:memory=memory --prefetch-multiplier:memory=10 \
--queues:translate=translate --prefetch-multiplier:translate=4 \
--concurrency:backup=1 --queues:backup=backup --prefetch-multiplier:backup=2"
# Logging configuration
# - %n will be replaced with the first part of the nodename.
# - %I will be replaced with the current child process index
# and is important when using the prefork pool to avoid race conditions.
CELERYD_PID_FILE="/run/celery/weblate-%n.pid"
CELERYD_LOG_FILE="/var/log/celery/weblate-%n%I.log"
CELERYD_LOG_LEVEL="INFO"
使用 logrotate 来旋转 Celery 记录的额外配置将被放置为 /etc/logrotate.d/celery
:
/var/log/celery/*.log {
weekly
missingok
rotate 12
compress
notifempty
}
使用 Celery beat 的周期性任务
Weblate 带有内建的定时任务设置。然而您可以在 settings.py
中定义另外的任务,例如请参见 惰性提交 。
任务应该由 Celery beats 守护进程执行。在不能正常工作的情况下,它可能不会运行,或者其数据库崩溃。在这样的情况下检查 Celery 启动日志,来找出根本原因。
监测 Celery 状态
你可以在 管理界面 中找到 Celery 任务队列的当前长度,或者你可以使用在命令中使用 celery_queues
。如果队列太长,你也会在管理界面中得到配置错误。
警告
Celery 错误默认之存储在 Celery 日志中,并且用户不可见。在您想要了解故障概况的情况下,推荐配置 收集错误报告 。
监测 Weblate
Weblate 提供了 /healthz/
URL,可用于简单的健康检查,例如使用 Kubernetes。Docker 容器内置了使用此 URL 的健康检查。
For monitoring metrics of Weblate you can use GET /api/metrics/
API endpoint.
收集错误报告
与其他任何软件一样,Weblate 可能会失败。为了收集有用的故障状态,我们推荐使用第三方服务来收集此类信息。这在 Celery 任务失败的情况下尤其有用,否则将只会向日志报告错误,而您不会收到有关它们的通知。Weblate 支持以下服务:
Sentry
Weblate 内置了对 Sentry 的支持。要使用它,只需在 settings.py
中设置 SENTRY_DSN
:
SENTRY_DSN = "https://id@your.sentry.example.com/"
Rollbar
Weblate 具有对 Rollbar 的内置支持。要使用它,只需遵循 Rollbar notifier for Python 的说明即可。
简而言之,您需要调整 settings.py
:
# Add rollbar as last middleware:
MIDDLEWARE = [
# … other middleware classes …
"rollbar.contrib.django.middleware.RollbarNotifierMiddleware",
]
# Configure client access
ROLLBAR = {
"access_token": "POST_SERVER_ITEM_ACCESS_TOKEN",
"client_token": "POST_CLIENT_ITEM_ACCESS_TOKEN",
"environment": "development" if DEBUG else "production",
"branch": "main",
"root": "/absolute/path/to/code/root",
}
其他所有内容都是自动集成的,您现在将同时收集服务器和客户端错误。
将 Weblate 迁移到其他服务其中
将 Weblate 迁移到其他服务器应该非常简单,然而它将数据存储在几个位置,您应该小心迁移。最佳的方式时停止 Weblate 再迁移。
迁移数据库
根据您的数据库后端,你可能有几个选项来迁移数据库。最直接的是将数据库转储到一个服务器上,并将它导入新的服务器中。另外,在数据库支持的情况下可以使用数据库复制。
最好的方式是使用数据库自带工具,因为它们通常最有效(例如 mysqldump 或 pg_dump )。如果您想要在不同的数据库之间迁移,唯一的选项恐怕是使用 Django 管理来转储并导入数据库:
# Export current data
weblate dumpdata > /tmp/weblate.dump
# Import dump
weblate loaddata /tmp/weblate.dump
迁移版本控制系统(VCS)仓库
存储在 DATA_DIR
下的版本控制系统(VCS)同样需要迁移。您可以简单地复制它们,或使用 rsync 来更有效地迁移。
其他注意事项
不要忘记移动 Weblate 会使用的其他服务,如 Redis、Cron 任务或自定义的身份验证后端。
Weblate 部署
Weblate 可以容易地安装到你的云中。请针对你的平台找到具体的指南:
用于 Weblate 的第三方部署
注解
以下部署不是由 Weblate 团队开发或支持的。部分设置可能与本文档中的描述有所不同。
Bitnami Weblate 栈
Bitnami 为很多平台提供 Weblate 栈 <https://bitnami.com/stack/weblate>。安装过程中会对设置进行调整,更多文档请参见 <https://bitnami.com/stack/weblate/README.txt>。
Weblate Cloudron 包
Cloudron 是自托管 web 应用的平台。安装有 Cloudron 的 Weblate 会自动更新。软件包由 Cloudron 团队在它们的 Weblate package repo 上维护。

YunoHost 中的 Weblate
自托管项目 YunoHost 为 Weblate提供了包。一旦安装了 YunoHost ,就可以同其它应用一样安装 Weblate 。它还为你提供带有备份和恢复的完全工作栈,但你必须为特定应用编辑设置文件。
可以使用管理界面,或这个按钮(它将带你到你的服务器):

还能够使用命令行界面:
yunohost app install https://github.com/YunoHost-Apps/weblate_ynh
升级 Weblate
Docker 镜像升级
官方 Docker 镜像(请参见 使用 Docker 安装)已经将所有升级步骤集成了。除了拉取最新的版本外没有手动步骤。
一般的升级指示
在升级前,请检查当前的 软件要求,因为他们可能被更改。一旦所有的要求被安装或升级,请调整你的 settings.py
,来匹配配置中的更改(正确的值请咨询 settings_example.py
)。
升级前,请务必查阅 与特定版本相关的指示。如果您要跳过某些版本,请按照升级中要跳过的所有版本的说明进行操作。有时最好先升级到某个中间版本,以确保顺利迁移。跨越多个版本的升级应该是可行的,但不像单一版本的升级那样经过良好的测试。
注解
推荐在升级前执行全数据库备份,使你可以在升级失败的情况下回滚数据库,请参见 备份和移动 Weblate。
停止 WSGI 和 Celery 进程。升级可能执行数据库的不兼容更改,因此在升级中避免旧的进程运行总是安全的。
升级 Weblate 代码。
对于 pip 安装,可以通过后面的来实现:
pip install -U "Weblate[all]"
If you don’t want to install all of the optional dependencies do:
pip install -U Weblate
通过 Git 核实,你需要取回新的源代码并升级你的安装:
cd weblate-src git pull # Update Weblate inside your virtualenv . ~/weblate-env/bin/pip install -e . # Install dependencies directly when not using virtualenv pip install --upgrade -r requirements.txt # Install optional dependencies directly when not using virtualenv pip install --upgrade -r requirements-optional.txt
New Weblate release might have new 可选依赖项, please check if they cover features you want.
升级配置文件,所需的步骤请参考
settings_example.py
或 与特定版本相关的指示。升级数据库架构:
weblate migrate --noinput
收集升级的静态文件(请参见 运行服务器 和 为静态文件提供服务):
weblate collectstatic --noinput --clear
压缩 JavaScript 和 CSS 文件(可选步骤,请参见 压缩客户资产 ):
weblate compress
如果你运行来自 Git 的版本,每次升级时还应该重新生成 locale 文件。可以通过调用后面的来进行:
weblate compilemessages
验证您的设置合理(还请参见 生产设置):
weblate check --deploy
重新启动 Celery worker (请参见 使用 Celery 的后台任务)。
与特定版本相关的指示
从 2.x 升级
如果从 2.x 发布版本升级,首先总是升级到 3.0.1,然后继续在 3.x 系列中升级。跳过这步的升级不被支持,并且会中断。
从 3.x 升级
如果从 3.x 发布版本升级,首先总是升级到 4.0.4 或 4.1.1,然后继续在 4.x 系列中升级。跳过这步的升级不被支持,并且会中断。
从 4.0 升级到 4.1
请按照 一般的升级指示 来执行升级。
显著的配置与依赖项更改:
在
settings_example.py
中有几项更改,最显著的是中间件的更改,请由此调整你的设置。有几个新的文件格式,在修改
WEBLATE_FORMATS
的情况下,你会想要将他们包括进来。有几个新的质量检查,在修改
CHECK_LIST
的情况下,你会想要将他们包括进来。在
DEFAULT_THROTTLE_CLASSES
设置中有几项更改,来允许在 API 中报告速率限制。有几个新的且更新的要求。
在
INSTALLED_APPS
中有一些更改。The
MT_DEEPL_API_VERSION
setting has been removed in Version 4.7. The DeepL machine translation now uses the newMT_DEEPL_API_URL
instead. You might need to adjustMT_DEEPL_API_URL
to match your subscription.
参见
从 4.1 升级到 4.2
请按照 一般的升级指示 来执行升级。
显著的配置与依赖项更改:
从 3.x 发布版本升级不再支持,请首先升级到 4.0 或 4.1。
有几个新的且更新的要求。
在
settings_example.py
中有几项更改,最显著的是新中间件和更改的应用订购。基于 JSON 格式的密钥是不再包括前导的点。在数据库迁移过程中调整字符串,但在你依赖于导出或 API 中的密钥时,外部组件会需要调整。
Celery 配置更改,不再使用
memory
队列。请调整你的启动脚本和CELERY_TASK_ROUTES
设置。现在在设置中配置 Weblate 域,请参见
SITE_DOMAIN`(或 :envvar:`WEBLATE_SITE_DOMAIN
)。在运行 Weblate 前你将不得不配置它。用户数据库上的用户名和电子邮件字段现在应该不因为大小写敏感而不同。它之前错误地没有被 PostgreSQL 强制。
参见
从 4.2 升级到 4.3
请按照 一般的升级指示 来执行升级。
显著的配置与依赖项更改:
在质量检查中有一些更改,在你调整
CHECK_LIST
的情况下会想将他们包括进来。源语言属性从项目移动到 API 中暴露的组件。在使用时你会需要更新 Weblate 客户端。
根据翻译的字符串数量,数据库迁移到 4.3 会花费很长时间(期望每 10 万个字符串的迁移时间大约为 1 小时)。
在
INSTALLED_APPS
中有一些更改。有个新的设置
SESSION_COOKIE_AGE_AUTHENTICATED
,补充了SESSION_COOKIE_AGE
。如果你使用 hub 或 lab 与 GitHub 或 GitLab 集成,则需要重新配置,请参见
GITHUB_CREDENTIALS
和GITLAB_CREDENTIALS
。
在 4.3.1 版更改:
Celery 配置更改,加入了
memory
队列。请调整你的启动脚本和CELERY_TASK_ROUTES
设置。
在 4.3.2 版更改:
附加组件的
post_update
方法现在加入额外 的skip_push
参数。
参见
从 4.3 升级到 4.4
请按照 一般的升级指示 来执行升级。
显著的配置与依赖项更改:
在
INSTALLED_APPS
中有一处更改, 必须将weblate.configuration
添加在那里。现在需要 Django 3.1。
在使用 MySQL 或 MariaDB 的情况下,需要的最低版本提高了,请参见 MySQL 和 MariaDB。
在 4.4.1 版更改:
单语 gettext 现在当出现时使用
msgid
和msgctxt
。这将改变此类文件中翻译字符串的标识,破坏到 Weblate 扩展数据,如截图或审查状态,的链接。请确保在升级之前提交对此类文件的待处理更改,并且建议你强制加载受影响的组件,方法是使用loadpo
。增加了 translate-toolkit 的最低要求版本,以解决几个文件格式问题。
参见
从 4.4 升级到 4.5
请按照 一般的升级指示 来执行升级。
显著的配置与依赖项更改:
The migration might take considerable time if you had big glossaries.
Glossaries are now stored as regular components.
The glossary API is removed, use regular translation API to access glossaries.
INSTALLED_APPS
中有一处更改——weblate.metrics
应被添加。
在 4.5.1 版更改:
There is a new dependency on the pyahocorasick module.
参见
从 4.5 升级到了 4.6
请按照 一般的升级指示 来执行升级。
显著的配置与依赖项更改:
有几个新的文件格式,在修改
WEBLATE_FORMATS
的情况下,你会想要将他们包括进来。创建组件的 API 现在自动使用 Weblate internal URLs,见:http:post:/api/projects/(string:project)/components/。
There is a change in dependencies and
PASSWORD_HASHERS
to prefer Argon2 for passwords hashing.
参见
从 4.6 升级到了 4.7
请按照 一般的升级指示 来执行升级。
显著的配置与依赖项更改:
在
settings_example.py
中有几项更改,最显著的是中间件的更改(MIDDLEWARE
),请由此调整你的设置。The DeepL machine translation now has a generic
MT_DEEPL_API_URL
setting to adapt to different subscription models more flexibly. TheMT_DEEPL_API_VERSION
setting is no longer used.现在需要 Django 3.2。
参见
从 4.7 升级到 4.8
请按照 一般的升级指示 来执行升级。
此版本中不需要额外的升级步骤。
参见
从 4.8 升级到 4.9
请按照 一般的升级指示 来执行升级。
There is a change in storing metrics, the upgrade can take long time on larger sites.
参见
从 Python 2 升级到 Python 3
Weblate 不再支持早于 3.5 版本的 Python。在仍然运行在较早版本的情况下,请首先在现有版本上执行到 Python 3 的迁移,并在后面进行升级。请参见 Upgrading from Python 2 to Python 3 in the Weblate 3.11.1 documentation。
从其它数据库迁移到 PostgreSQL
如果在 PostgreSQL 以外的数据库上运行 Weblate,你应该考虑迁移到 PostgreSQL,因为 Weblate 与它搭配表现最佳。后面的步骤将引导你在数据库之间迁移数据。请记住迁移前要停止 web 和 Celery 服务器,否则会导致不一致的数据。
创建 PostgreSQL 数据库
在另一个单独的数据库中运行 Weblate ,并将用户账户分开通常是个好方法:
# If PostgreSQL was not installed before, set the main password
sudo -u postgres psql postgres -c "\password postgres"
# Create a database user called "weblate"
sudo -u postgres createuser -D -P weblate
# Create the database "weblate" owned by "weblate"
sudo -u postgres createdb -E UTF8 -O weblate weblate
使用 Django JSON 转储来迁移
最简单的迁移方法是使用 Django JSON 转储。这对于较小的安装工作得很好。在更大的网站,你会想要使用 pgloader 代替,请参见 使用 pgloader 迁移到 PostgreSQL。
将 PostgreSQL 作为附加数据库连接添加到
settings.py
:
DATABASES = {
"default": {
# Database engine
"ENGINE": "django.db.backends.mysql",
# Database name
"NAME": "weblate",
# Database user
"USER": "weblate",
# Database password
"PASSWORD": "password",
# Set to empty string for localhost
"HOST": "database.example.com",
# Set to empty string for default
"PORT": "",
# Additional database options
"OPTIONS": {
# In case of using an older MySQL server, which has MyISAM as a default storage
# 'init_command': 'SET storage_engine=INNODB',
# Uncomment for MySQL older than 5.7:
# 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
# If your server supports it, see the Unicode issues above
"charset": "utf8mb4",
# Change connection timeout in case you get MySQL gone away error:
"connect_timeout": 28800,
},
},
"postgresql": {
# Database engine
"ENGINE": "django.db.backends.postgresql",
# Database name
"NAME": "weblate",
# Database user
"USER": "weblate",
# Database password
"PASSWORD": "password",
# Set to empty string for localhost
"HOST": "database.example.com",
# Set to empty string for default
"PORT": "",
},
}
运行迁移,并将任何插入到表格中的数据 drop 掉:
weblate migrate --database=postgresql
weblate sqlflush --database=postgresql | weblate dbshell --database=postgresql
将遗留数据库进行转储,并导入 PostgreSQL
weblate dumpdata --all --output weblate.json
weblate loaddata weblate.json --database=postgresql
调整
DATABASES
而只使用 PostgreSQL 数据库作为默认,将遗留连接删除掉。
现在 Weblate 应该准备好从 PostgreSQL 数据库运行了。
使用 pgloader 迁移到 PostgreSQL
pgloader 是通用迁移工具,将数据迁移到 PostgreSQL。你可以使用它来迁移 Weblate 数据库。
调整 settings.py 文件而将 PostgreSQL 用作数据库。
迁移 PostgreSQL 中的模式:
weblate migrate weblate sqlflush | weblate dbshell
运行 pgloader 来转移数据。后面的脚本可以用于迁移数据库,但你会想要学习更多关于 pgloader 的知识,来理解它做什么以及调整它来匹配你的设置:
LOAD DATABASE FROM mysql://weblate:password@localhost/weblate INTO postgresql://weblate:password@localhost/weblate WITH include no drop, truncate, create no tables, create no indexes, no foreign keys, disable triggers, reset sequences, data only ALTER SCHEMA 'weblate' RENAME TO 'public' ;
从 Pootle 迁移
因为 Weblate 开始编写出来替换 Pootle,所以支持从 Pootle 迁移用户账户。你可以将 Pootle 的用户转储,并使用 importusers
将他们导入。
备份和移动 Weblate
使用 BorgBackup 进行的自动化备份
3.9 新版功能.
Weblate 内置了对使用 BorgBackup 创建服务备份的支持。Borg 创建了节省空间的加密备份,可以安全地存储在云中。可以从管理界面中的 Backups 选项卡上控制备份。
在 4.4.1 版更改: PostgreSQL 和 MySQL/MariaDB 数据库都包括在自动备份中。
使用 Borg 的备份是增量的,Weblate 被配置为保留以下备份:
每天备份之前 14 天的内容
前 8 周的每周备份
前 6 个月的每月备份

Borg 加密密钥
BorgBackup 创建加密的备份,如果没有密码,你将无法恢复它们。密码是在添加新的备份服务时生成的,你应该复制它并将其保存在一个安全的地方。
如果你在使用 Weblate 提供的备份存储,请同样备份你的私有 SSH 密钥,因为它用来访问你的备份。
参见
定制备份
可通过
DATABASE_BACKUP
配置数据库备份。The backup creation can be customized using
BORG_EXTRA_ARGS
.
Weblate 提供的备份存储
备份你的 Weblate 实例的最简单方式是购买 `weblate.org 的备份服务<https://weblate.org/support/#backup>`_。这是你如何让它运行起来的方式:
在 https://weblate.org/support/#backup 购买 备份服务。
在管理界面输入得到的密钥,请参见 集成支持 。
Weblate 将连接到云服务,并获取备份的访问信息。
在 Backups 选项卡下开启新的备份配置。
备份你的 Borg 凭据,以便能够恢复备份,请参见 Borg 加密密钥 。
提示
为了安全起见,有打开所有东西的手动步骤。没有你的同意,就不会有数据发送到通过注册步骤得到的备份仓库。
使用客户的备份存储
也可以使用自己的存储来备份。 SSH 可以用于在远程目的地存储备份,目标服务器需要安装 BorgBackup 。
参见
Borg 文档中的 General
本地文件系统
推荐去指定本地备份的绝对路径,例如 /path/to/backup。该目录必须可由运行 weblate 的用户写入(请参见 文件系统权限)。在目录不存在的情况下,Weblate 会尝试新建它,但需要适当的权限才能这么做。
提示
在 Docker 中运行 Weblate时,请确保备份位置暴露为来自 Weblate 容器的一个卷。否则,备份文件将在其所在的容器重启时被 Docker 丢弃。
一个选项是将备份放置在一个现有的卷中。例如, /app/data/borgbackup
。这是容器中的一个现有的卷。
你也可以在 Docker 的编写文件中为备份目的添加一个新的容器,例如使用 /borgbackup
:
services:
weblate:
volumes:
- /home/weblate/data:/app/data
- /home/weblate/borgbackup:/borgbackup
备份所存储的目录由 UID 1000 所有,否则 Weblate 将无法把备份写入那里。
远程备份
要创建远程备份,你必须将 BorgBackup 安装到另一台服务器上,你的 Weblate 部署要能使用如下 Weblate SSH 密钥通过 SSH 访问此服务器:
准备一个用于存储备份的服务器。
在上面安装SSH服务器(大多数Linux发行版默认情况下都会安装SSH服务器)。
Install BorgBackup on that server; most Linux distributions have packages available (see Installation).
选择一个现有用户或创建一个用于备份的新用户。
为用户添加 Weblate SSH 密钥,使 Weblate 可以在不需要密码的情况下 SSH 到服务器(参见 Weblate SSH 密钥)。
将 Weblate 备份位置配置为
user@host:/path/to/backups
或ssh://user@host:port/path/to/backups
.
提示
Weblate 提供的备份存储 为你提供毫不费力的自动远程备份。
从 BorgBackup 恢复
恢复功能会访问你的备份仓库,并准备备份密码。
用
borg list REPOSITORY
列出服务器上的所有备份。使用
borg extract REPOSITORY::ARCHIVE
将所需备份恢复到当前目录。从放置在 Weblate 数据目录下
backup
目录中的 SQL 备份中恢复数据库(请参见 下载的数据用于备份)。将 Weblate 配置 (
backups/settings.py
,请参见 下载的数据用于备份 )复制到正确的位置,请参见 调整配置 。When using Docker container, the settings file is already included in the container and you should restore the original environment variables. The
environment.yml
file might help you with this (see 下载的数据用于备份).将整个存储的数据目录复制到
DATA_DIR
所配置的位置。使用 Docker 容器时,将数据置于数据卷,见 Docker 容器卷。
请确保文件有正确的权限,见:ref:file-permissions。
Borg 会话可能看上去是这个样子的:
$ borg list /tmp/xxx
Enter passphrase for key /tmp/xxx:
2019-09-26T14:56:08 Thu, 2019-09-26 14:56:08 [de0e0f13643635d5090e9896bdaceb92a023050749ad3f3350e788f1a65576a5]
$ borg extract /tmp/xxx::2019-09-26T14:56:08
Enter passphrase for key /tmp/xxx:
手动备份
取决于你想保存什么, Weblate 存储的类型数据会备份在各自的位置。
提示
如果你正进行手动备份,你也许想要关闭 Weblate 关于缺乏备份的警告,方法是添加 weblate.I028
到 settings.py
中的 SILENCED_SYSTEM_CHECKS
;对于 Docker,则是 WEBLATE_SILENCED_SYSTEM_CHECKS
。
SILENCED_SYSTEM_CHECKS.append("weblate.I028")
数据库
实际存储位置取决于数据库的设置。
提示
数据库是最重要的存储。定期对数据库进行备份。没有数据库,所有的翻译都会消失。
本地数据库备份
推荐的方式是使用数据库自带工具如 pg_dump 或 mysqldump 来保存数据库的转储。这通常比 Django 备份表现得好,并且可以连同数据一道,恢复完整表格。
你可以在较新的 Weblate 发行版中恢复这个备份,当运行于 migrate
时,它将执行所有必需的迁移。请参考 升级 Weblate 了解如何在版本间升级的更多详细信息。
Django 数据库备份
另外,可以使用 Django 的 dumpdata
命令备份你的数据库。那种方式是不依托数据库的,并且可以用于先要更改数据库后端的情况。
恢复数据库之前,你需要确保恢复备份和执行备份的实例运行的是完全相同的 Weblate 版本。这是必要的,因为数据库结构在不同版本之间会发生变化,你可能会以某种方式破坏数据。安装相同版本后,用 migrate
运行所有数据库迁移。
之后,一些条目将已经在数据库中创建,你也会在数据库备份中看到它们。推荐的方法是使用管理 shell 手动删除这些条目 (见:ref:invoke-manage):
weblate shell
>>> from weblate.auth.models import User
>>> User.objects.get(username='anonymous').delete()
文件
如果你有足够的备份空间,只需备份整个 DATA_DIR
。这是一个安全带,即使它包含一些你不想要的文件。下面的部分详细描述了应该备份和可以跳过的内容。
下载的数据用于备份
在 4.7 版更改: 环境变量被转储在 environment.yml
,以帮助在 Docker 中恢复环境。
存储在 DATA_DIR
/backups
中。
Weblate 这里备份各种数据,可以包括这些文件用于更完整的备份。文件每日更新(需要运行 Celery beat 服务器,请参见 使用 Celery 的后台任务 )。当前,这包括:
Weblate 设置为
settings.py
(还有扩展版,在settings-expanded.py
)。PostgreSQL 数据库备份为
database.sql
。环境变量转储在
environment.yml
。
数据库备份默认保存为纯文本,但也可以通过 :setting:`DATABASE_BACKUP`来进行压缩或整个跳过。
要恢复数据库备份,请使用数据库工具加载它,例如:
psql --file=database.sql weblate
版本控制仓库
版本控制存储库包含带有 Weblate 更改的上游存储库的副本。如果你对所有翻译组件启用了:ref:component-push_on_commit`,那么所有 Weblate 变化都包括在上游。不需要在 Weblate 端备份存储库,因为它们可以从上游位置再次克隆,不会丢失数据。
SSH 和 GPG 密钥
存储在 DATA_DIR
/ssh
和 DATA_DIR
/home
中。
如果正在使用 Weblate 生成的 SSH 或 GPG 密钥,你应该备份这些位置。否则将丢失私有密钥,并且你将不得不重新生成新的密钥。
用户上传的文件
存储在 DATA_DIR
/media
中。
你应当备份所有用户上传的文件(例如 字符串的可视化上下文 )。
Celery 任务
Celery 任务队列可能会包含一些信息,但通常无需进行备份。你最多会丢失尚未被翻译记忆库处理的更新。无论如何,建议在恢复时执行全文或存储库更新,这样就不会有丢失这些内容的问题。
手动备份的命令行
使用 cron 作业,您可以设置一条每天执行的 Bash 命令,例如:
$ XZ_OPT="-9" tar -Jcf ~/backup/weblate-backup-$(date -u +%Y-%m-%d_%H%M%S).xz backups vcs ssh home media fonts secret
`XZ_OPT`后面引号之间的字符串允许你选择自己的 xz 选项,例如用于压缩的内存量;见 https://linux.die.net/man/1/xz
你可以根据需要调整文件夹和文件的列表。为了避免保存翻译记忆库(在备份文件夹中),你可以使用:
$ XZ_OPT="-9" tar -Jcf ~/backup/weblate-backup-$(date -u +%Y-%m-%d_%H%M%S).xz backups/database.sql backups/settings.py vcs ssh home media fonts secret
恢复手动备份
将已经备份的所有数据恢复。
使用
updategit
更新所有仓库。weblate updategit --all
移动 Weblate 安装
按照上面备份与恢复说明,将你的安装迁移到不同系统。
身份验证
注册用户
Weblate 的默认设置使用 python-social-auth ,网站上处理新用户注册的一种形式。确定电子邮箱后,新用户可以通过使用一种第三方服务来贡献或证实。
还可以使用 REGISTRATION_OPEN
关闭新用户注册。
身份验证尝试服从于 频次限制 。
身份验证后端
Django的内置解决方案用途是进行身份验证,包括用各种社交登录选项进行验证。使用它意味着可以导入基于 Django 其他项目的用户数据库(请参见 从 Pootle 迁移 )。
也可以另外新建 Django,相对于其他方式进行身份验证。
参见
身份验证设置 描述了如何配置官方 Docker 镜像的身份验证。
密码身份验证
默认 settings.py
与一组合理的设置 AUTH_PASSWORD_VALIDATORS
在一起:
密码不能与其它个人信息太相似。
密码必须包含 10 个字符。
密码不能是通常使用的密码。
密码不能完全是数字。
密码不能包括单个字符或只有空白字符。
密码与你过去使用的密码不匹配。
可以自定义这个设置来匹配密码政策。
可以另外安装 django-zxcvbn-password 这会非常实际地估计密码的难度,并允许拒绝低于下面适当阈值的密码。
SAML 身份验证
4.1.1 新版功能.
请遵守 Python Social Auth 的指示来配置。显著的差异有:
Weblate 支持单一 IDP ,在
SOCIAL_AUTH_SAML_ENABLED_IDPS
中被称为weblate
。SAML XML 元数据 URL 为
/accounts/metadata/saml/
。后面的设置自动填入:
SOCIAL_AUTH_SAML_SP_ENTITY_ID
、SOCIAL_AUTH_SAML_TECHNICAL_CONTACT
、SOCIAL_AUTH_SAML_SUPPORT_CONTACT
配置的例子:
# Authentication configuration
AUTHENTICATION_BACKENDS = (
"social_core.backends.email.EmailAuth",
"social_core.backends.saml.SAMLAuth",
"weblate.accounts.auth.WeblateUserBackend",
)
# Social auth backends setup
SOCIAL_AUTH_SAML_SP_ENTITY_ID = f"https://{SITE_DOMAIN}/accounts/metadata/saml/"
SOCIAL_AUTH_SAML_SP_PUBLIC_CERT = "-----BEGIN CERTIFICATE-----"
SOCIAL_AUTH_SAML_SP_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----"
SOCIAL_AUTH_SAML_ENABLED_IDPS = {
"weblate": {
"entity_id": "https://idp.testshib.org/idp/shibboleth",
"url": "https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO",
"x509cert": "MIIEDjCCAvagAwIBAgIBADA ... 8Bbnl+ev0peYzxFyF5sQA==",
"attr_name": "full_name",
"attr_username": "username",
"attr_email": "email",
}
}
SOCIAL_AUTH_SAML_ORG_INFO = {
"en-US": {
"name": "example",
"displayname": "Example Inc.",
"url": "http://example.com"
}
}
SOCIAL_AUTH_SAML_TECHNICAL_CONTACT = {
"givenName": "Tech Gal",
"emailAddress": "technical@example.com"
}
SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {
"givenName": "Support Guy",
"emailAddress": "support@example.com"
}
默认配置从以下属性提取用户详细信息,通过配置您的IDP来配置它们:
属性 |
SAML URI 参照 |
---|---|
全名 |
|
名字 |
|
姓氏 |
|
电子邮箱 |
|
用户名 |
|
提示
上面的例子和 Docker 镜像定义了一个 IDP 并且标记为 weblate
。 您可能需要在 IDP 中将此字符串配置为 Relay 。
LDAP 身份验证
LDAP 身份验证可以使用 django-auth-ldap 软件包而最好地实现。可以使用通常的方式安装:
# Using PyPI
pip install django-auth-ldap>=1.3.0
# Using apt-get
apt-get install python-django-auth-ldap
提示
此包包含于 Docker 容器中,见 使用 Docker 安装。
注解
在 Python LDAP 3.1.0 模块中有一些不兼容,导致可能无法使用那个版本。如果得到错误信息 AttributeError: ‘module’ object has no attribute ‘_trace_level’ ,将 python-ldap 降回到 3.0.0 版可能会有帮助。
一旦安装了软件包,就可以将其钩入 Django 身份验证了:
# Add LDAP backed, keep Django one if you want to be able to sign in
# even without LDAP for admin account
AUTHENTICATION_BACKENDS = (
"django_auth_ldap.backend.LDAPBackend",
"weblate.accounts.auth.WeblateUserBackend",
)
# LDAP server address
AUTH_LDAP_SERVER_URI = "ldaps://ldap.example.net"
# DN to use for authentication
AUTH_LDAP_USER_DN_TEMPLATE = "cn=%(user)s,o=Example"
# Depending on your LDAP server, you might use a different DN
# like:
# AUTH_LDAP_USER_DN_TEMPLATE = 'ou=users,dc=example,dc=com'
# List of attributes to import from LDAP upon sign in
# Weblate stores full name of the user in the full_name attribute
AUTH_LDAP_USER_ATTR_MAP = {
"full_name": "name",
# Use the following if your LDAP server does not have full name
# Weblate will merge them later
# 'first_name': 'givenName',
# 'last_name': 'sn',
# Email is required for Weblate (used in VCS commits)
"email": "mail",
}
# Hide the registration form
REGISTRATION_OPEN = False
注解
你应当从设置的 AUTHENTICATION_BACKENDS
部分移除 'social_core.backends.email.EmailAuth'
,否则用户不能够在 Weblate 中设置他们的密码,并使用它进行身份验证。为了生成权限和方便匿名用户,仍需保留 'weblate.accounts.auth.WeblateUserBackend'
。它还允许你使用一个本地管理帐户登录,如果你已经创建了它 (如通过使用 createadmin
)。
使用绑定密码
如果可以为身份验证使用直接绑定,那么需要使用搜索,并为用户搜索提供绑定,例如:
import ldap
from django_auth_ldap.config import LDAPSearch
AUTH_LDAP_BIND_DN = ""
AUTH_LDAP_BIND_PASSWORD = ""
AUTH_LDAP_USER_SEARCH = LDAPSearch(
"ou=users,dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)"
)
Active Directory 集成
import ldap
from django_auth_ldap.config import LDAPSearch, NestedActiveDirectoryGroupType
AUTH_LDAP_BIND_DN = "CN=ldap,CN=Users,DC=example,DC=com"
AUTH_LDAP_BIND_PASSWORD = "password"
# User and group search objects and types
AUTH_LDAP_USER_SEARCH = LDAPSearch(
"CN=Users,DC=example,DC=com", ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)"
)
# Make selected group a superuser in Weblate
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
# is_superuser means user has all permissions
"is_superuser": "CN=weblate_AdminUsers,OU=Groups,DC=example,DC=com",
}
# Map groups from AD to Weblate
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
"OU=Groups,DC=example,DC=com", ldap.SCOPE_SUBTREE, "(objectClass=group)"
)
AUTH_LDAP_GROUP_TYPE = NestedActiveDirectoryGroupType()
AUTH_LDAP_FIND_GROUP_PERMS = True
# Optionally enable group mirroring from LDAP to Weblate
# AUTH_LDAP_MIRROR_GROUPS = True
CAS 身份验证
可以使用软件包如 django-cas-ng 来实现 CAS 身份验证。
第一步通过 CAS 揭示了用户电子邮箱字段。这必须在 CAS 服务器自身来配置,并需要至少运行 CAS v2 ,因为 CAS v1 不支持属性。
第二步更新 Weblate ,来使用 CAS 服务器和属性。
为了安装 django-cas-ng :
pip install django-cas-ng
一旦安装了软件包,就可以通过修改 settings.py
文件将其钩连到 Django 身份验证系统:
# Add CAS backed, keep the Django one if you want to be able to sign in
# even without LDAP for the admin account
AUTHENTICATION_BACKENDS = (
"django_cas_ng.backends.CASBackend",
"weblate.accounts.auth.WeblateUserBackend",
)
# CAS server address
CAS_SERVER_URL = "https://cas.example.net/cas/"
# Add django_cas_ng somewhere in the list of INSTALLED_APPS
INSTALLED_APPS = (..., "django_cas_ng")
最后,可以使用信号将电子邮箱字段投射到用户对象上。为了生效,必须将信号从 django-cas-ng 软件包导入,并将你的代码与这个信号连接。在设置文件中这样做可能产生问题,这样建议将它放进去:
在你的 app 配置的
django.apps.AppConfig.ready()
方法在项目的
urls.py
文件中(当没有模块存在时)
from django_cas_ng.signals import cas_user_authenticated
from django.dispatch import receiver
@receiver(cas_user_authenticated)
def update_user_email_address(sender, user=None, attributes=None, **kwargs):
# If your CAS server does not always include the email attribute
# you can wrap the next two lines of code in a try/catch block.
user.email = attributes["email"]
user.save()
配置第三方 Django 身份验证
一般地,任何 Django 身份认证插件应该可以在 Weblate 上工作。只需要按照插件的说明,只记住安装了 Weblate 用户后台。
典型的安装包括,将身份验证后台添加到 AUTHENTICATION_BACKENDS
,并将身份验证 app (如果有的话)安装到 INSTALLED_APPS
:
AUTHENTICATION_BACKENDS = (
# Add authentication backend here
"weblate.accounts.auth.WeblateUserBackend",
)
INSTALLED_APPS += (
# Install authentication app here
)
访问控制
Weblate 带有细粒度的权限系统,可以为整个实例或在有限范围内分配用户权限。
在 3.0 版更改: 在 Weblate 3.0 之前,权限系统只基于 Django 权限系统,但现在是专门为 Weblate 构建的。如果使用的是更旧的版本,那么请查阅所使用的特定版本的文档。
简单的访问控制
如果你不是掌控完整的 Weblate 安装,而仅仅是需要访问管理当前项目(如在 Hosted Weblate),你的访问控制管理选项将被设置所限制。如果你不需要任何复杂的步骤,这些就足够了。
项目访问控制
注解
此功能对于在 Hosted Weblate 上运行自由套餐的项目不可用。
您可以通过选择不同的 访问控制 设置来限制用户对单个项目的访问。可用的选项有:
- 公开的
公开可见,且所有登录用户均可进行翻译。
- 受保护的
公开可见,但只允许被选择的用户翻译。
- 私有的
公开可见,但只允许被选择的用户翻译。
- 自定义
可以在每个项目的配置( 管理 ↓ 设置)的 Access 选项卡中更改 访问控制。

可以通过 DEFAULT_ACCESS_CONTROL
更改默认值。
注解
即使是 私有 项目,也会暴露有关项目的一些信息:尽管进行了访问控制设置,但整个实例的统计信息和语言概况仍将包括所有项目的计数。你的项目名称和其他信息不会因此暴露。
注解
Weblate 实例管理员可通过 自定义设置 重新定义 公开 、 受保护 和 私有 项目中默认提供的用户权限组合。
警告
通过打开 Custom 访问控制, Weblate 会删除所有为一个选定项目建立的 special groups。如果你在没有整个 Weblate 实例的管理员权限的情况下这样做,你会立即丢失管理项目的权限。
参见
管理每个项目的访问控制
有 Manage project access 特权的用户(请参见 权限列表 )还可以通过 非 自定义 访问控制来管理用户。它们可以将用户分配到以下组之一。
适用于 公开 、 受保护 和 私有 项目:
- 管理
包括项目可用的所有权限。
- 复查(只有在 review workflow 开启的情况下才会出现)
可以在复查时批准翻译。
只限 受保护 和 私有 项目:
- 翻译
可以翻译项目,并将离线的翻译上传。
- 原文
可以编辑源字符串(如果 project settings 中允许的话)及源字符串信息。
- 语言
可以管理翻译语言(添加或删除翻译)。
- 术语表
可以管理术语表(添加或删除条目,并上传)。
- 记忆存储
可以管理翻译记忆库。
- 截图
可以管理截屏(添加或删除截屏,并将其与源字符串关联)。
- 版本控制系统(VCS)
可以管理版本控制系统(VCS)并访问导出的仓库。
- 账单
可以访问账单信息和设置(请参见 账单 )。
遗憾地,暂时不能够更改这个预前定制好的列组。同时这方法并不能够给予所有用户加上一些额外权限。
注解
对于非 自定义 访问控制,每个项目实际上都定义了上述每个群组的实例。 这些组的实际名称将是 Project@Group
,也以这种方式显示在 Django 管理界面中。但是无法在 Weblate 用户界面编辑它们。

这些功能可在 Access control 页面上找到,可以从项目的菜单 Manage ↓ Users 进入。
邀请新用户
此外,除了将现有用户添加到项目之外,还可以邀请新用户。将立即创建任何新用户,但是该帐户将保持不活动状态,直到使用通过电子邮件发送的邀请中的链接登录为止。不需要具有任何站点范围的权限,就可以这么做,项目级别的访问管理权限(如 Administration 组成员资格)就足够了。
提示
如果被邀请的用户错过了邀请的有效性,则可以在密码重置表单中使用被邀请的电子邮件地址设置密码,因为已经创建了帐户。
3.11 新版功能: 可以重新发送用户邀请电子邮件(将使之前发送的所有邀请失效)。
通过 Users 选项卡下的 management interface 获取可在站点范围内使用的相同类型的邀请。
阻止用户
4.7 新版功能.
如果有些用户在您的项目中行为不佳,您可以选择阻止他们进行贡献。 如果被阻止的用户有权限,那他仍然可以看到项目,但他将不能贡献。
每个项目的权限管理
你可以将你的项目设置为 Protected 或 Private ,并在 Weblate 的界面上进行每个项目的 用户管理。
默认情况下,这可防止 Weblate 因 用户 和 查看者 默认组 本身的配置而授予其提供的访问权限。但这并不妨碍您向这些项目授予站点范围的权限,可用的方法有改变默认组、创建一个新的组,或如下方 自定义访问控制 中所述为单个组件创建额外的自定义设置。
通过 Weblate 用户界面管理权限的一个主要好处是,您可以将其委托给其他用户,而无需授予他们超级用户权限。为此,请将 TA 们添加到项目的 Administration 组中。
自定义访问控制
注解
此功能对于在 Hosted Weblate 上运行自由套餐的项目不可用。
权限系统基于组和角色,其中角色定义了一组权限,组将它们链接到用户和翻译,请参阅 用户、角色、用户组和权限 获取更多详细信息。
Weblate 访问控制系统最强大的功能目前只能通过 Django admin interface 来实现。 您可以使用它来管理任何项目的权限。你不一定要切换到 Custom access control 来使用它。 但是你必须有超级用户权限才能使用它。
如果您对实现的细节不感兴趣,只是想创建一个基于默认值的足够简单的配置,或者不能访问整个 Weblate 安装(如 Hosted Weblate),请参见 简单的访问控制 部分。
通用设置
本节包含一些您可能感兴趣的常见配置的概述。
站点范围内的权限管理
要一次性管理整个实例的权限,请将用户添加到适当的 默认组:
Users (默认情况下,这是由 automatic group assignment 完成的)。
Reviewers (如果您有专门的评审人员和 review workflow)。
管理者 (如果您想把大部分的管理操作委托给别人)。
您应该将所有项目配置为 Public`(参见 :ref:`acl),否则 用户 和 审阅者 组成员提供的站点范围权限将不起任何作用。
您还可以向默认组授予一些您选择的额外权限。例如,你可能想给所有 用户 管理截图的权限。
您还可以定义一些新的自定义组。如果希望继续在站点范围内管理这些组的权限,请为 Project selection 选择一个合适的值(如 All projects 或 All public projects)。
语言、组件或项目的自定义权限
您可以创建自己的专用组来管理不同对象(如语言、组件和项目)的权限。虽然这些组只能授予额外的权限,但您不能通过添加另一个自定义组来撤销全站或每个项目组授予的任意权限。
示例:
如果您希望(不管出于什么原因)只允许一组封闭的可靠翻译者来进行特定语言(比如 捷克语)的翻译,同时将其他语言的翻译保持公开,你必须:
移除所有用户翻译 捷克语 的权限。在默认配置中,这可以通过修改 Users default group 来实现。
Users 用户组 语言选择
定义
语言
除了 捷克语
为 捷克语 翻译者添加一个专门的小组。
捷克语翻译者 小组 角色
高级用户
项目选择
所有公共项目
语言选择
定义
语言
捷克语
将您希望授予此权限的用户添加到此组中。
如您所见,这种方式的权限管理功能强大,但可能是一项相当乏味的工作。 您不能将其委托给其他用户,除非授予超级用户权限。
用户、角色、用户组和权限
身份验证模型由几个对象组成:
- 权限
Weblate 定义的个人权限。权限不能分配给用户。这只能通过分配角色来完成。
- 角色
角色定义了一组权限。 这允许在多个地方重用这些集,使管理更加容易。
- User
用户可以属于多个组。
- 群组
分组连接角色、用户和身份验证对象(项目、语言和组件列表)。
注解
一个组可以不分配任何角色,但在这种情况下任何人都可以浏览它的项目(见下文)。
浏览到项目的访问权限
用户必须是链接到项目的组或项目中的任何组件的成员。拥有成员身份就足够了,浏览项目不需要特定的权限 (这被用于默认的 查看者 小组,见 群组列表 )。
浏览组件的权限
用户一旦能够访问组件的项目,就可以不受限制地访问组件。(并将拥有该项目授予用户的所有权限)。在开启 受限制的访问 的情况下,访问组件需要对该组件(或该组件所在的组件列表)具有显式权限。
群组范围
组内角色分配的权限范围适用如下规则:
如果群组指定了任何 组件列表,则授予该组成员的所有权限都适用于附加到该组的组件列表中的所有组件,并为这些组件所在的所有项目授予没有额外权限的访问权。组件 和 项目 被忽略。
If the group specifies any Components, all the permissions given to the members of that group are granted for all the components attached to the group, and an access with no additional permissions is granted for all the projects these components are in. Projects are ignored.
Otherwise, if the group specifies any Projects, either by directly listing them or by having Projects selection set to a value like All public projects, all those permissions are applied to all the projects, which effectively grants the same permissions to access all projects unrestricted components.
The restrictions imposed by a group’s Languages are applied separately, when it’s verified if a user has an access to perform certain actions. Namely, it’s applied only to actions directly related to the translation process itself like reviewing, saving translations, adding suggestions, etc.
提示
使用 Language selection 或 Project selection 来自动包括所有语言或项目。
示例:
假设有一个项目
foo
包含以下组件:foo/bar
和foo/baz
,以及以下群组:
西班牙语审稿管理员 小组 角色
审核字符串、管理代码库
组件
foo/bar
语言
西班牙语
该组的成员将具有以下权限(假设是默认的角色设置):
对整个项目
foo
的一般(浏览)访问,包括其中的两个组件:foo/bar
和foo/baz
。复查
foo/bar
西班牙语翻译(不是在其他地方)中的字符串。Manage VCS for the whole
foo/bar
repository e.g. commit pending changes made by translators for all languages.
自动分配组
On the bottom of the Group editing page in the Django admin interface, you can specify Automatic group assignments, which is a list of regular expressions used to automatically assign newly created users to a group based on their e-mail addresses. This assignment only happens upon account creation.
The most common use-case for the feature is to assign all new users to some
default group. In order to do so, you will probably want to keep the default
value (^.*$
) in the regular expression field. Another use-case for this option might be to
give some additional privileges to employees of your company by default.
Assuming all of them use corporate e-mail addresses on your domain, this can
be accomplished with an expression like ^.*@mycompany.com
.
注解
从一个 Weblate 版本升级到另一个版本时总是会重新创建对 用户 和 查看者 的用户组分配。如果你想关闭它,将正则表达式设置为 ^$
(不匹配任何内容)。
注解
就目前而言,还没有办法通过用户界面将现有用户批量添加到某个组。 为此,您可以通过 REST API 来实现。
默认组和角色
安装完成后,将创建一组默认组(参见 群组列表)。
这些角色和组是在安装时创建的。 升级时,内置角色始终通过数据库迁移保持最新状态。你实际上无法更改它们,如果要定义自己的权限组合,请定义一个新角色。
权限列表
账单(请参见 账单)
查看账单信息[Administration, Billing]
变更
下载更改[Administration]
评论
发表评论 [Administration, Edit source, Power user, Review strings, Translate]
删除评论 [Administration]
组件
编辑组件设置[Administration]
锁定组件,防止翻译 [Administration]
术语表
添加术语表入口[Administration, Manage glossary, Power user]
编辑术语表入口[Administration, Manage glossary, Power user]
删除术语表入口[Administration, Manage glossary, Power user]
上传术语表入口[Administration, Manage glossary, Power user]
自动建议
使用自动建议 [Administration, Edit source, Power user, Review strings, Translate]
翻译记忆库
编辑翻译记忆库 [Administration, Manage languages]
删除翻译记忆库 [Administration, Manage languages]
项目
编辑项目设置[Administration]
更改项目访问权限[Administration]
报告
下载报告[Administration]
截图
添加截屏[Administration, Manage screenshots]
编辑截屏[Administration, Manage screenshots]
删除截屏[Administration, Manage screenshots]
源字符串
编辑附加的字符串信息 [Administration, Edit source]
字符串
添加新字符串 [Administration]
移除一条字符串 [Administration]
忽略未通过的检查 [Administration, Edit source, Power user, Review strings, Translate]
编辑字符串 [Administration, Edit source, Power user, Review strings, Translate]
复查字符串[Administration, Review strings]
当建议被强制执行时编辑字符串 [Administration, Review strings]
编辑源字符串[Administration, Edit source, Power user]
建议
接受建议 [Administration, Edit source, Power user, Review strings, Translate]
添加建议 [Administration, Edit source, Add suggestion, Power user, Review strings, Translate]
删除建议 [Administration, Power user]
为建议投票 [Administration, Edit source, Power user, Review strings, Translate]
翻译
添加翻译语言 [Administration, Power user, Manage languages]
执行自动翻译 [Administration, Automatic translation]
删除现有翻译 [Administration, Manage languages]
下载翻译文件 [Administration, Edit source, Access repository, Power user, Review strings, Translate, Manage languages]
添加多种翻译语言 [Administration, Manage languages]
上传
定义所上传翻译的作者 [Administration]
使用上传的内容覆盖现有的字符串[Administration, Edit source, Power user, Review strings, Translate]
上传翻译 [Administration, Edit source, Power user, Review strings, Translate]
版本控制系统(VCS)
访问内部仓库 [Administration, Access repository, Power user, Manage repository]
将更改提交到内部代码库[Administration, Manage repository]
从内部存储库推送更改 [Administration, Manage repository]
重置内部代码库的更改 [Administration, Manage repository]
查看上游仓库位置 [Administration, Access repository, Power user, Manage repository]
更新内部代码库[Administration, Manage repository]
全网站范围的特权
使用管理界面
添加新项目
添加语言定义
管理语言定义
管理群组
管理用户
管理角色
管理公告
管理翻译记忆库
管理组件列表
注解
站点范围的特权不会被授予任何默认角色。它们功能强大,非常接近超级用户的地位。它们中的大多数都会影响到你的 Weblate 安装中的所有项目。
群组列表
下面的群组在安装时建立(或在执行 setupgroups
后), 您可以自由修改它们。但是,如果它们被删除或重命名,迁移后将重新创建这些名称。
- 访客
定义非授权用户的权限。
这个群组只包括匿名用户(请参见
ANONYMOUS_USER_NAME
)。你可以从群组中去掉角色,来限制非授权用户的权限。
默认角色: Add suggestion, Access repository
- 查看者
这一角色确保公开项目对所有用户可见。默认情况下,所有用户都是该组的成员。
默认情况下, automatic group assignment 将会使所有新帐户在加入时成为该组的成员。
默认角色:无
- 用户
所有用户的默认群组。
默认情况下, automatic group assignment 将会使所有新帐户在加入时成为该组的成员。
默认角色: Power user
- 校对
复核员的群组(参见 翻译工作流 )。
默认角色: Review strings
- 管理者
管理员的群组。
默认角色: Administration
警告
决不要移除预先定义的 Weblate 群组和用户,因为这会这可能会导致意想不到的问题!如果你不需要他们,你可以删除他们的所有特权。
额外访问限制
If you want to use your Weblate installation in a less public manner, i.e. allow
new users on an invitational basis only, it can be done by configuring Weblate
in such a way that only known users have an access to it. In order to do so, you can set
REGISTRATION_OPEN
to False
to prevent registrations of any new
users, and set REQUIRE_LOGIN
to /.*
to require logging-in to access
all the site pages. This is basically the way to lock your Weblate installation.
提示
您可以使用内置的 invitations 来添加新用户。
翻译项目
翻译组织
Weblate 将项目/组件的可翻译版本控制系统(VCS)内容组织成树状结构。
底层对象是 项目配置,该项目配置应将所有翻译归在一起(例如,多个版本的应用程序翻译和/或随附的文档)。
在上面的级别上,即 组件配置,实际上是要翻译的组件,您定义要使用的版本控制系统(VCS)仓库以及要翻译的文件掩码。
在 组件配置 上方有单独的翻译,当版本控制系统(VCS)仓库中出现翻译文件(与 组件配置 中定义的 文件掩码 匹配)时,Weblate 会自动处理这些翻译。
Weblate 支持 Translate Toolkit 支持的多种翻译格式(双语和单语),请参阅 支持的文件格式。
注解
您可以使用 Weblate internal URLs 共享克隆的版本控制系统(VCS)仓库。当您有许多共享同一版本控制系统(VCS)的组件时,强烈推荐使用此功能。它提高了性能并减少了所需的磁盘空间。
添加翻译项目和组件
在 3.2 版更改: 已包含用于添加项目和组件的界面,您不再需要使用 Django 管理界面。
在 3.4 版更改: 现在,添加组件的过程是多阶段的,可以自动发现大多数参数。
根据你的权限,可以创建新的翻译项目和组件。具备 Add new projects 权限的用户总是可以这么做。如果你的实例使用付费托管(如 https://hosted.weblate.org/,请参见 账单),你还可以从管理账单的用户账户基于套餐限额创建它们。
您可以在单独的页面上查看当前的付费套餐:

您可以从此处开始创建项目,也可以使用导航栏中的菜单来填写翻译项目的基本信息以完成添加:

创建项目后,您将直接进入项目页面:

只需单击一次即可启动创建新翻译组件的操作。创建组件的过程是多阶段的,并自动检测大多数翻译参数。有几种创建组件的方法:
- 从版本控制
从远程版本控制仓库创建组件。
- 从现有组件
通过选择不同的文件为现有组件创建其他组件。
- 其他分支
仅针对不同分支,为现有组件创建其他组件。
- 上传翻译文件
如果您没有版本控制或不想将其与 Weblate 集成,则将翻译文件上传到 Weblate。您以后可以使用网络界面或 Weblate 的 REST API 更新内容。
- 翻译文档
上传单个文档或翻译文件并进行翻译。
- 从头开始
创建空白翻译项目并手动添加字符串。
一旦有了现有的翻译组件,就可以使用同一仓库轻松地为其他文件或分支添加新的组件。
首先,您需要填写名称和仓库位置:

在下一页上,将显示已发现的可翻译资源的列表:

最后,您检查翻译组件信息并填写可选详细信息:

参见
项目配置
创建一个翻译项目,然后在其中添加一个新的翻译组件。这个项目就像一个架子,里面堆放着真正的翻译。同一项目中的所有组件共享建议及其字典;翻译也将自动传播到单个项目中的所有组件(除非在组件配置中关闭),请参见 翻译记忆库。
参见
这些基本属性被新建并通知翻译人员项目:
项目名称
详细的项目名称,用于显示项目名称。
URL slug
适用于 URL 的项目名称。
项目网站
译者可以在其中找到有关该项目的更多信息的 URL。
This is a required parameter unless turned off by WEBSITE_REQUIRED
.
翻译说明
Text describing localization process in the project, and any other information useful for translators. Markdown can be used for text formatting or inserting links.
设置 “Language-Team” 文件头
Weblate 是否应管理 Language-Team
头(目前这是仅 GNU gettext 功能)。
访问控制
配置每个项目的访问控制,请参阅 项目访问控制 以获取更多详细信息。
可以通过 DEFAULT_ACCESS_CONTROL
更改默认值。
启用复查
允许复核翻译的工作流程,请参见 专门的审核者。
启用原文复查
允许复核源字符串的工作流程,请参见 源字符串复查。
启用钩子
是否将未经身份验证的 通知钩子 用于此仓库。
语言别名
将翻译导入到Weblate时定义语言代码映射。当您的存储库中的语言代码不一致,并且您希望在Weblate中获得一致的视图,或者如果您想使用翻译文件的非标准命名时,可以使用此方法。
典型的使用情况会是将 美国英语映射到英语:en_US:en
由逗号分隔的多个映射:en_GB:en,en_US:en
使用非标准代码:ia_FOO:ia
提示
当匹配翻译文件时映射语言代码,并且映射是大小写敏感的,所以您确保使用与文件名中使用的形式相同的源语言代码。
参见
组件配置
组件是用于翻译的内容的分组。您输入版本控制系统(VCS)仓库位置和想要翻译那个文件的掩码,Weblate 会自动地从 这个版本控制系统(VCS)中取回,并找到所有匹配的翻译文件。
参见
您可以在 支持的文件格式 中找到一些典型配置的例子。
注解
推荐将翻译文件保持在合理的大小——在您的案例中使用任何合理的工具(独立的 app 或插件、书籍的章节或网站)来分割翻译文件。
Weblate 能够轻松处理 10000 个字符串,但大的翻译组件的分割工作和翻译者之间的协调更困难。
如果翻译的语言定义丢失,会新建一个空的定义,并且命名为 “cs_CZ (generated)”。您应该调整定义,并将其反馈给 Weblate 的作者,从而丢失的语言可以包括在下一次的发布版本中。
使用版本控制系统(VCS)工作的所有重要参数都包含在组件中,并且从中取出翻译:
组件名称
冗长组件名称,用于显示组件的名称。
组件标识串
适用于 URLs 的组件名称。
组件项目
组件所属的 项目配置。
版本控制系统
使用的版本控制系统(VCS),细节请参见: 版本控制集成。
源代码库
版本控制系统(VCS)仓库,用于拉取更改。
参见
指定 URLs 的更多细节请参见 Accessing repositories 。
提示
这可以或者是真实的版本控制系统(VCS)的 URL, 或者是 weblate://project/component
,指示了仓库应该与其它组件分享。更多细节请参见 Weblate internal URLs。
代码库推送 URL
用于推送的仓库 URL。这个设置用于 Git 和 Mercurial,并且当这个空白时推送支持为这些关闭。
For linked repositories, this is not used and setting from linked component applies.
参见
关于如何指定仓库 URL 的更多细节请见 Accessing repositories,并且关于从 Weblate 推送更改的更多细节,请参见 推送 Weblate 的更改 。
代码库浏览器
用于显示源文件(所用消息的位置)的存储库浏览器的 URL。此处为空时,将不生成这样的链接。你可以使用 模板标记。
例如在 GitHub 上,使用类似:https://github.com/WeblateOrg/hello/blob/{{branch}}/{{filename}}#L{{line}}
如果你的路径是相对于不同文件夹的(路径包含 ..
),您可能想使用 parentdir
过滤器(见 模板标记)来剥除前导文件夹:https://github.com/WeblateOrg/hello/blob/{{branch}}/{{filename|parentdir}}#L{{line}}
已导出代码库 URL
由 Weblate 进行的更改被导出的 URL。当不使用 持续本地化 时,或者当需要手动合并更改时,这是重要的。您可以为 Git 仓库使用 Git 导出器,来将其自动化。
仓库分支
从版本控制系统(VCS)核实哪个分支,以及从哪里寻找翻译。
For linked repositories, this is not used and setting from linked component applies.
推送分支
用于推送更改的分支,留为空白来使用 仓库分支。
For linked repositories, this is not used and setting from linked component applies.
注解
此功能目前只支持Git、GitLab和GitHub,无法在其他VCS集成中工作。
文件掩码
要翻译的文件的掩码,包括路径。它应包含一个“*”替换语言代码(有关处理方式的信息,请参阅 语言定义)。如果您的仓库包含多个翻译文件(例如,多个 gettext 域),则您需要为每个文件创建一个组件。
例如 po/*.po
或 locale/*/LC_MESSAGES/django.po
。
如果文件名包含特殊字符(例如 [
或 ]
),则需要将这些特殊字符转义为 [[]
或 []]
。
单语言译文模版语言文件
包含字符串定义的译文模板文件,用于 单语言组件。
编辑译文模版文件
对于 单语言组件 是否允许编辑译文模板文件。
中间语言文件
对于 单语言组件 的单一语言文件。在多数情况下,这是开发者提供的翻译文件,并且在新建真正的源字符串时使用。
设置时,源字符串基于此文件,但所有其他语言都基于 单语言译文模版语言文件。如果字符串没有被翻译成源语言,则禁止翻译成其他语言。这提供了 Quality gateway for the source strings。
新翻译的译文模版
用于生成新翻译的译文模板文件,例如 gettext 的 .pot
文件。
提示
在很多单语言格式中,Weblate 默认以空白文件开始。新建新的翻译时,在您想要所有的字符串都以空值出现的情况下来使用。
文件格式
翻译文件格式,还请参见 支持的文件格式。
源字符串缺陷报告地址
用于报告上游缺陷的电子邮箱地址。这个地址还会收到在 Weblate 中作出的任何源字符串评论的通知。
允许同步翻译
您可以关闭项目内从其它组件到这个组件的翻译的传播。这实际上取决于您要翻译的内容,有时最好能多次使用同一个翻译。
对于单语言翻译,除非您跨越整个项目中使用相同的 ID,通常关闭它是个好主意。
默认值可以通过 DEFAULT_TRANSLATION_PROPAGATION
来更改。
参见
启用建议
对于这个组件,建议的翻译是否被接受。
建议投票
为建议打开投票,请参见 建议投票。
自动接受建议
自动接收被投票的建议,请参见 建议投票。
翻译标记
质量检查和其他 Weblate 行为的定制,请参见 使用标记定制行为。
强制检查
检查哪个不能被忽视的列表,请参见 强制检查。
翻译许可证
翻译的许可(不需要与源代码的许可证相同)。
贡献者协议
翻译此组件前需先同意的用户协议。
添加新翻译
如何处理创建新语言的请求。可用选项:
- 联系维护者
用户可以选择所需的语言,项目维护者将收到有关该语言的通知。由他们决定是否向仓库添加(或不添加)语言。
- 显示翻译介绍
向用户显示的页面链接描述了开始新翻译的过程。如果需要更正式的过程(例如,在开始实际翻译之前组成人员团队),请使用此选项。
- 创建新语言文件
用户可以选择语言,然后 Weblate 会自动为其新建文件并开始翻译。
- 禁用添加新翻译
用户将无法选择开始新的翻译。
提示
The project admins can add new translations even if it is disabled here when it is possible (either 新翻译的译文模版 or the file format supports starting from an empty file).
管理字符串
4.5 新版功能.
Configures whether users in Weblate will be allowed to add new strings and remove existing ones. Adjust this to match your localization workflow - how the new strings are supposed to be introduced.
For bilingual formats, the strings are typically extracted from the source code (for example by using xgettext) and adding new strings in Weblate should be disabled (they would be discarded next time you update the translation files). In Weblate you can manage strings for every translation and it does not enforce the strings in all translations to be consistent.
For monolingual formats, the strings are managed only on source language and are automatically added or removed in the translations. The strings appear in the translation files once they are translated.
语言代码风格
自定义 Weblate 创建的用于生成翻译文件名的语言代码。
合并方式
您可以配置如何处理上游仓库的升级。对于一些版本控制系统(VCS),这会不需要支持。更多细节请参见 合并或变基。
默认值可以由 DEFAULT_MERGE_STYLE
更改。
提交、添加、删除、合并以及插件信息
当提交翻译时使用的消息,请参见 模板标记。
默认值可由 DEFAULT_ADD_MESSAGE
、DEFAULT_ADDON_MESSAGE
、DEFAULT_COMMIT_MESSAGE
、DEFAULT_DELETE_MESSAGE
、DEFAULT_MERGE_MESSAGE
来更改。
提交时推送
是否提交更改应该被自动推送到上游仓库。当允许时,一旦 Weblate 将更改提交给基础仓库,推动就被启动(请参见 惰性提交)。为了真正允许推送,还要配置 Repository push URL。
对变更进行提交的延时时间
设置在后台任务或 commit_pending
管理命令提交更改前,这些更改存在的时长(以小时为单位)。一旦存在至少一个比该时长更旧的更改,便会提交组件中的所有更改。
默认值可以由 COMMIT_PENDING_HOURS
更改。
提示
There are other situations where pending changes might be committed, see 惰性提交.
出错时锁定
在第一次推送或合并到上游仓库失败后,锁定该组件(及其链接组件,参见 Weblate internal URLs),或从上游仓库拉出。这样可以避免增加必须手动解决的冲突。
一旦仓库没有故障留下来了,组件将会自动解锁。
源语言
用于源字符串的语言。如果您要翻译的不是英语,请更改此选项。
提示
如果你正在从英语翻译双语文件,但又希望能够在英语翻译中进行修复,选择 English (Developer) 作为一种源语言以避免源语言和现有翻译之间名称上的冲突。
对于单语言翻译,您可以使用这种情况下的中间翻译,请参见 中间语言文件。
语言筛选
当扫描文件掩码时用于将翻译过滤的正则表达式。它可以用于限制 Weblate 管理的语言列表。
注解
单出现在文件名中时,您需要列出语言代码。
过滤的一些例子:
过滤器的描述 |
正则表达式 |
---|---|
只有选择的语言 |
|
排除的语言 |
|
只筛选两个字母的代码 |
|
排除非语言文件 |
|
包括所有文件(默认) |
|
正则表达式变体
用于确定字符串变体的正则表达式,请见 字符串变体。
注解
多数字段可以由项目所有者或管理者在 Weblate 界面上编辑。
优先级
高优先级的组件将最先提供给翻译者。
受限制的访问
组件默认对访问项目的任何人都可见,即使不能在组件中进行任何更改。这会容易地使翻译在项目内保持一致。
Restricting access at a component, or component-list level takes over access permission to a component, regardless of project-level permissions. You will have to grant access to it explicitly. This can be done through granting access to a new user group and putting users in it, or using the default custom or private access control groups.
默认设置可在 DEFAULT_RESTRICTED_COMPONENT
中更改。
提示
这也应用于项目管理员—请确认切换状态后,您不会丢失对组件的访问。
用作一个术语
4.5 新版功能.
允许使用该组件作为术语表。您可以配置其列出方式,借助 术语颜色。
The glossary will be accessible in all projects defined by 在项目中分享.
It is recommended to enable 管理字符串 on glossaries in order to allow adding new words to them.
参见
术语颜色
Display color for a glossary used when showing word matches.
模板标记
Weblate 在几个需要进行文本渲染的地方使用了简单的标记语言。它基于 Django 模板语言,所以它可以非常强大。
当前它用在:
可以在组件模板中得到后面的变量:
{{ language_code }}
语言代码
{{ language_name }}
语言名称
{{ component_name }}
组件名称
{{ component_slug }}
组件标识串
{{ project_name }}
项目名称
{{ project_slug }}
项目标识串
{{ url }}
翻译 URL
{{ filename }}
翻译文件名
{{ stats }}
翻译统计数据,这具有进一步的属性,示例如下。
{{ stats.all }}
字符串总量计数
{{ stats.fuzzy }}
需要复查的字符串计数
{{ stats.fuzzy_percent }}
需要复查的字符串百分比
{{ stats.translated }}
翻译的字符串计数
{{ stats.translated_percent }}
翻译的字符串百分比
{{ stats.allchecks }}
带有未通过检查的字符串数量
{{ stats.allchecks_percent }}
带有未通过检查的字符串百分比
{{ author }}
当前提交的作者,只在提交范围可用。
{{ addon_name }}
当前执行的插件名称,旨在插件提交信息中可用。
后面的变量在仓库浏览器或编辑器模板中可用:
{{branch}}
当前的分支
{{line}}
文件的行数
{{filename}}
文件名,您也可以使用
parentdir
过滤器,例如{{filename|parentdir}}
,来剥除前导部分
您可以将它们与过滤器结合:
{{ component|title }}
您可以使用条件:
{% if stats.translated_percent > 80 %}Well translated!{% endif %}
有另外的标签用于替换字符:
{% replace component "-" " " %}
您可以将它与过滤器结合:
{% replace component|capfirst "-" " " %}
还有另外的过滤器来操作文件名:
Directory of a file: {{ filename|dirname }}
File without extension: {{ filename|stripext }}
File in parent dir: {{ filename|parentdir }}
It can be used multiple times: {{ filename|parentdir|parentdir }}
……以及其他 Django 模板特性。
导入速度
从版本控制系统(VCS)仓库获取并将翻译导入 Weblate 可能会是漫长的过程,具体取决于您的翻译的大小。以下是一些提示:
优化配置
默认配置对于测试和调试 Weblate 很有用。而对于生产设置,您应该做一些调整。许多调整对性能有相当大的影响。请查阅 生产设置 了解详情,特别是:
配置 Celery 来执行后台任务(请参见 使用 Celery 的后台任务)
检查资源的限制
如果导入巨大的翻译或仓库,您会遭到服务器资源限制的打击。
检查空闲内存的量,通过操作系统来缓存翻译,将极大地提高性能。
如果有很多字符串需要处理的话,磁盘操作会是瓶颈——磁盘被 Weblate 和数据库施加压力。
另外的 CPU 核心会帮助提高后台任务的性能(请参见 使用 Celery 的后台任务)。
禁止不必要的检查
一些质量检查可能相当昂贵,如果不需要,在导入时省略可以节省一些时间。配置的信息请参见 CHECK_LIST
。
自动新建组件
在您的项目有十多个翻译文件的情况下(例如不同的 gettext 域,或 Android 应用的一部分),您会想要将它们自动导入。可以通过使用 import_project
或 import_json
,或者通过安装 组件发现 插件,通过命令行来实现。
为了使用插件,首先您需要为一个翻译文件(选择未来最不可能改名或删除的那个)新建组件,并且在这个组件上安装插件。
对于管理命令,您需要新建包含所有组件的项目,然后运行 import_project
或 import_json
。
语言定义
为了恰当地呈现不同的翻译,需要提供有关语言名称、文本方向、复数定义和语言代码的信息。
分析语言代码
当分析翻译时,Weblate 试图将语言代码(通常为 ISO 639-1)映射到任何现有的语言对象。
您可以通过 语言别名 在项目层次来进一步调整这种映射。
如果无法找到精确的匹配,将尝试把其融入一种现有的语言。已尝试以下措施:
大小写不敏感的查询。
将下划线和破折号标准化。
查询内置的语言别名。
按语言名称查找。
忽略给定语言的默认国家地区代码——选择
cs
而非cs_CZ
。
如果这也失败了,将使用默认值(从左到右的文本方向,一个复数)创建一个新的语言定义。自动创建的代码为 xx_XX
的语言将被命名为 xx_XX (generated)。您可能想稍后在管理界面中更改这个(见 更改语言定义),并将它报告给问题跟踪器(见 为 Weblate 作贡献),这样的话,正确的定义就可以添加到即将发布的 Weblate 版本中。
提示
在您看到有些不想要的内容作为语言的情况下,您会想要调整 语言筛选 ,当分析翻译时忽略这样的文件。
更改语言定义
您可以在语言界面来更改语言定义( /languages/
URL )。
当编辑时,确认所有字段都是正确的(特别是复数和正文方向),否则译者将不能正常编辑这些翻译。
内置语言定义
Weblate 中包含了大约 600 种语言的定义,而且该语言列表在每个发行版中都会进行扩展。每当 Weblate 升级时(更准确地说,每当 weblate migrate 被执行时,请参见 一般的升级指示)语言数据库都会更新,以包含 Weblate 提供的所有语言定义。
这个特性可以使用 UPDATE_LANGUAGES
来禁止。还可以使用 setuplang
来强制更新数据库,从而匹配 Weblate 内建数据。
参见
歧义语言代码和宏语言
在很多情况下,为翻译使用宏语言代码不是个好主意。典型出问题的情况会是库尔德语,会根据实际的变体以阿拉伯语或拉丁语脚本撰写。为了在 Weblate 中得到正确的行为,推荐只使用单独的语言代码,并且避免宏语言。
参见
宏语言定义 <https://iso639-3.sil.org/about/scope#Macrolanguages>,宏语言列表 <https://iso639-3.sil.org/code_tables/macrolanguage_mappings/data>
语言定义
每种语言都包括后面的字段:
语言代码
识别语言的代码。 Weblate 使用两个字母代码,如 ISO 639-1 所定义的,但对于没有两个字母代码的语言,使用会使用 ISO 639-2 或 ISO 639-3 代码。它还支持 BCP 47 定义的扩展代码。
语言名称
语言的可见名称。还要根据用户界面语言将 Weblate 中包括的语言名称进行本地化。
文字方向
确定语言是从右向左还是从左向右书写。对于多数语言这个属性都能够正确地自动监测。
复数数量
语言中使用的复数的数量。
复数式
Gettxt 兼容的复数公式,用于确定根据给定的数量使用哪种复数形式。
添加新的翻译
在 2.18 版更改: 在 2.18 以前的版本中,添加新的翻译的行为因文件格式而不同。
Weblate 可以为所有文件格式自动开始新的翻译。
一些格式希望以一个空文件开始,并只包含已翻译的字符串(如 Android 字符串资源),而另一些格式则希望包含所有 key(如 GNU gettext)。基于文档的格式(如 OpenDocument Format)以源文档的副本开始,所有字符串均被标记为需要编辑。某些情况下,这实际上并不取决于格式,而更取决于用来处理翻译的框架(如使用 JSON 文件)。
当在 组件配置 中指定 新翻译的译文模版 时,Weblate 将使用这个文件开始新的翻译。当执行时任何现有翻译将从文件中删除。
当 新翻译的译文模版 是空的,并且文件格式支持时,新建空文件,一旦新的字符串被翻译就添加进去。
语言代码风格 允许在生成的文件名中将语言代码个性化:
- 基于文件格式的默认值
取决于文件格式,对于其中的多数使用 POSIX。
- POSIX 风格使用下划线作为分隔
通常由 gettext 和相关工具使用,生成像
pt_BR
这样的语言代码。- POSIX 风格使用下划线作为分隔,包括国家地区代码
POSIX 风格的语言代码即使不必要时也包括国家地区代码(例如
cs_CZ
)。- GCP 风格使用连字符作为分隔
通常用于网络平台,生成像
pt-BR
这样的语言代码。- GCP 风格使用连字符作为分隔,包括国家地区代码
BCP 风格的语言代码即使不必要时也包括国家地区代码(例如
cs_CZ
)。- Android 风格
只在 Android 应用中使用,生成
pt-rBR
这样的语言代码。- Java 风格
由 Java 使用——多数 BCP 带有用于中文的遗留代码。
此外,语言别名 中定义的任何映射都反向应用。
注解
Weblate 在解析翻译文件时能识别其中的任何一种,上面的设置只影响新文件的创建方式。
持续本地化
有适当的基础结构,因此你的翻译紧随开发。这样,翻译人员可以一直进行翻译,而不必在发布之前处理大量的新文本。
参见
与 Weblate 集成 描述了将您的开发集成到 Weblate 中的基本方式。
这是过程:
开发人员进行更改并将其推送到版本控制系统(VCS)仓库。
可以选择更新翻译文件(这取决于文件格式,请参阅 当已经更新了模板时,为什么 Weblate 仍然显示旧的字符串?)。
Weblate 从版本控制系统(VCS)仓库中拉取更改,请参阅 更新仓库。
一旦 Weblate 检测到翻译更改,便会根据翻译者的订阅设置通知他们。
翻译者使用 Weblate Web 界面提交翻译,或上传离线更改。
翻译者完成后,Weblate 会将更改提交到本地仓库(请参阅 惰性提交),如果有权限将其推回(请参阅 推送 Weblate 的更改)。
更新仓库
你应该设置某种方式,从后端仓库的源头更新它们。
使用 通知钩子 来与多数常见的代码托管服务集成:
在仓库管理中或使用 Weblate 的 REST API 或 Weblate 客户端 来手动触发更新
启用
AUTO_UPDATE
以自动更新你的 Weblate 实例上的所有组件执行
updategit
(选择项目,或--all
来更新全部)
每当Weblate更新存储库时,更新后插件都将被触发,请参见: 附加组件 。
避免合并冲突
当同一文件在 Weblate 内外都被更改时,就会出现来自 Weblate 的合并冲突。有两种方法可以解决这个问题——避免在 Weblate 之外进行编辑,或者将 Weblate 整合到您的更新过程中,这样就可以在更新 Weblate 外部的文件之前刷新更改。
第一种方法容易用于单语言文件——可以添加 Weblate 之内的新字符串,并将文件的整个编辑留在那里。对于双语文件,通常存在某种消息提取过程而从源代码产生翻译文件。在一些情况下,这可以分成两部分——一部分用于提取过程产生模板(例如使用 xgettext 产生 gettex POT ),然后下一步过程将它合并到真正的翻译中(例如使用 msgmerge 更新 gettext PO 文件)。可以在 Weblate 中执行第二步,它将确认在这个操作前所有待定的更改都包括进去了。
第二种方法可以这样实现,使用 Weblate 的 REST API ,当你在自己一侧进行更改时,强制 Weblate 推送所有待定的更改,并锁定翻译。
进行更新的脚本看起来像这样:
# Lock Weblate translation
wlc lock
# Push changes from Weblate to upstream repository
wlc push
# Pull changes from upstream repository to your local copy
git pull
# Update translation files, this example is for Django
./manage.py makemessages --keep-pot -a
git commit -m 'Locale updates' -- locale
# Push changes to upstream repository
git push
# Tell Weblate to pull changes (not needed if Weblate follows your repo
# automatically)
wlc pull
# Unlock translations
wlc unlock
如果多个组件分享相同的仓库,需要分别将他们全部锁定:
wlc lock foo/bar
wlc lock foo/baz
wlc lock foo/baj
注解
例子使用了 Weblate 客户端,这需要配置(API 密钥)来远程控制 Weblate。可以通过使用 HTTP 客户端代替 wlc 来实现这一点,例如 curl,请参见 Weblate 的 REST API。
参见
从 GitHub 自动接收更改
Weblate 自带对 GitHub 的原生支持。
如果使用 Hosted Weblate ,推荐的方法是安装 Weblate app,该方法能够得到正确的设置,而不必设置很多东西。它还可以用于将更改推送回来。
为了在每次推送到 GitHub 仓库时接收通知,将 Weblate Webhook 添加到仓库设置( Webhooks )中,如下图所示:

对于负载 URL,将 /hooks/github/
增补到你的 Weblate URL中,例如对于 Hosted Weblate 服务,这是 https://hosted.weblate.org/hooks/github/
。
可以将其他设置保留为默认值( Weblate 可以处理内容类型,并只消费 push 事件)。
从 Bitbucket 自动接收更改
Weblate 已经支持 Bitbucket webhooks ,添加仓库推送时触发的 webhook ,目的地为你的 Weblate 安装上的 /hooks/bitbucket/
(例如 https://hosted.weblate.org/hooks/bitbucket/
)。

从 GitLab 自动接收更改
Weblate 已经支持 GitLab hooks ,添加项目的 webhook ,目的地为你的 Weblate 安装上的 /hooks/gitlab/
(例如 https://hosted.weblate.org/hooks/gitlab/
)。
从 Pagure 自动接受更改
3.3 新版功能.
Weblate 已经支持 Pagure hooks ,添加项目的 webhook ,目的地为你的 Weblate 安装上的 /hooks/pagure/
(例如 https://hosted.weblate.org/hooks/pagure/
)。这可以在 Project options 之下的 Activate Web-hooks 中完成:

从 Azure Repos 自动接收更改
3.8 新版功能.
Weblate 已经支持 Azure Repos web hooks ,为 Code pushed 事件添加 webhook ,目的地为你的 Weblate 安装上的 /hooks/azure/
URL (例如 https://hosted.weblate.org/hooks/azure/
)。这可以在 Project settings 之下的 Service hooks 中完成。
从 Gitea Repos 自动接收更改
3.9 新版功能.
Weblate 已经支持 Gitea webhooks ,为 Push events 事件添加 Gitea Webhook ,目的地为你的 Weblate 安装上的 /hooks/gitea/
URL (例如 https://hosted.weblate.org/hooks/gitea/
)。这可以在 Settings 之下的 Webhooks 中完成。
从 Gitee Repos 自动接收更改
3.9 新版功能.
Weblate 已经支持 Gitee webhooks ,为 Push 事件添加 Webhook ,目的地为你的 Weblate 安装上的 /hooks/gitee/
URL (例如 https://hosted.weblate.org/hooks/gitee/
)。这可以在 Management 之下的 Webhooks 中完成。
每晚自动更新仓库
Weblate 在后面合并更改时,每晚自动获取远程仓库来提高性能。可以选择将其同样转换为进行每晚合并,通过允许 AUTO_UPDATE
。
推送 Weblate 的更改
每个翻译组件可以新建推送 URL(请参见 代码库推送 URL ),在那种情况下 Weblate 能够将更改推送到远程仓库。 Weblate 还可以配置在每次提交时自动推送更改(这是默认的,请参见 提交时推送 )。如果不想更改自动给推送,可以在 Repository maintenance 之下手动进行,或通过 wlc push
使用 API。
推送选项根据使用的 版本控制集成 而不同,更多细节可以在那个章节中找到。
如果不想要 Weblate 的直接推送,系统也支持 GitHub 、 GitLab、 Pagure 的拉取请求或 Gerrit 审核。 你可以通过在 组件配置 中选择 GitHub 、 GitLab 、 Gerrit 或 Pagure 作为 版本控制系统 来激活这些。
整体上, Git 、 GitHub 和 GitLab 可以具有后面的选项:
需要的设置 |
|||
---|---|---|---|
不推送 |
空 |
空 |
|
直接推送 |
SSH URL |
空 |
|
推送到单独的分支 |
SSH URL |
分支名称 |
|
来自分叉的 GitHub 拉取请求 |
空 |
空 |
|
来自分支的 GitHub 拉取请求 |
SSH URL 1 |
分支名称 |
|
来自分叉的 GitLab 合并请求 |
空 |
空 |
|
来自分支的 GitLab 结合请求 |
SSH URL 1 |
分支名称 |
|
来自分叉的 Pargue 合并请求 |
空 |
空 |
|
来自分支的 Pagure 合并请求 |
SSH URL 1 |
分支名称 |
注解
还可以允许 Weblate 提交后更改的自动推送,这可以在 提交时推送 中完成。
参见
请参见 Accessing repositories 来设置 SSH 密钥,和 惰性提交 获得关于 Weblate 决定提交更改的信息。
受保护的分支
如果在受保护的分支上使用 Weblate ,可以配置使用拉取请求,并执行翻译的实际复查(对你不知道的语言可能有问题)。另一个方法是去掉对 Weblate 推送用户的这个限制。
例如在 GitHub ,这可以在仓库配置中进行:

合并或变基
默认情况下,Weblate 会将上游存储库合并到自己的存储库中。如果您还通过其他方式访问底层存储库,这是最安全的方式。如果你不需要这样做,则可以启用对上游更改的变基,这将生成具有更少合并提交的历史。
注解
在复杂融合的情况下,变基可能使你产生麻烦,因此请仔细考虑是否允许它们。
与他人交互
Weblate 通过使用它的 API ,使与他人的交流更容易。
惰性提交
Weblate 会尽可能将同一作者的提交分组到一个提交中。这大大减少了提交的数量,但是如果你想同步版本控制系统(VCS)仓库,例如合并,你可能需要明确地告诉它去做提交(这对 管理者 组是默认允许的,参见 权限列表)。
一旦后面的任何条件满足,这种模式的更改将被提交:
某人另外更改了已经被更改的字符串。
来自上游的结合发生了。
明确地请求了提交。
更改比 组件配置 上定义为 Age of changes to commit 的时间段更陈旧。
提示
每个组件都建立提交。所以在具有很多组件的情况下,仍然会看到很多提交。在这种情况下你会使用 压缩(Squash) Git 提交 插件。
如果想要更频繁地提交更改,并且不检查新旧,可以安排周期定时性任务来执行提交:
CELERY_BEAT_SCHEDULE = {
# Unconditionally commit all changes every 2 minutes
"commit": {
"task": "weblate.trans.tasks.commit_pending",
# Ommiting hours will honor per component settings,
# otherwise components with no changes older than this
# won't be committed
"kwargs": {"hours": 0},
# How frequently to execute the job in seconds
"schedule": 120,
}
}
用脚本处理仓库
定制 Weblate 与仓库交互的方式是 附加组件 。关于如何通过插件执行外部脚本的信息,请咨询 从附加组件执行脚本 。
跨组件保持翻译一致
一旦具有多个翻译组件,你会想要确保相同的字符串具有相同的翻译。这可以在几个层次实现。
翻译宣传
当 允许同步翻译 处于启用状态时(这是默认的,请参见 组件配置 ),在所有的组件中字符串匹配时,所有新的翻译自动进行。在所有的组件中这样的翻译都适当地归功于当前翻译的用户。
注解
翻译宣传需要密钥来匹配单语言翻译格式,因此在建立翻译密钥匙请记住。
一致性检查
只要字符串存在差异,就会触发 不一致的 检查。可以利用此检查来手动复查这些差异,并选择正确的翻译。
自动化翻译
基于不同组件的自动翻译,可以是跨组件同步翻译的方式。可以或者手动触发(请参见 自动化翻译 ),或者使用插件( 自动化翻译 )在仓库更新时自动运行。
翻译许可
您可以指定翻译输入哪种授权方式。当翻译对公众公开时这特别重要,这样明确规定如何使用。
您应该指定 组件配置 许可证信息。您应该避免要求与贡献者签订许可协议,尽管这是可能的。
许可证信息
在指定许可证信息的时候(许可证名称和 URL )后,这个信息将显示在各个 组件配置 的翻译信息部分。
如果不需要特别同意的话,这通常是放置许可信息的最佳位置。如果您的项目或翻译不是自由的,您很可能需要事先同意。
贡献者协议
如果您指定了贡献者许可协议,那么只有同意该协议的用户能够作贡献。在访问翻译时,这是一个清晰可见的步骤:

输入的文本被格式化为段落,并且可以包括外部链接。不能使用 HTML 标记。
用户许可证
任何用户都可以在其个人资料中查看实例上所有公共项目的所有翻译许可证:

翻译进程
建议投票
每个人可以默认添加建议,由登录用户来接受。当超过一名登录用户同意时,建议投票结果可以使用字符串,通过 Suggestion voting 设置 组件配置,来打开投票,并且通过 Autoaccept suggestions 来设置接受建议的阈值(如果投票的话,这也包括来自提出建议的用户的投票)。
注解
一旦设置了自动接受,普通用户会失去直接保存翻译或接受建议的权限。要绕过这一点,可以通过 当建议强制时编辑字符串 permission。
您可以将这些与 access control 结合起来,形成下列设置之一:
用户提出建议并对建议进行投票,由一个有限的小组控制采纳的内容。——打开投票。——关闭自动接受。——不允许用户保存翻译。
用户提出建议并对建议进行投票,一旦有规定数量的用户同意,就自动接受。——打开投票。——设置自动接受所需要的投票数量。
对建议的可选投票。(当用户对做出的多个建议不确定时,可以由用户可选地使用。)——只打开投票。
源字符串另外的信息
通过向字符串添加额外的信息来增强翻译过程,这些信息包括解释、字符串优先级、检查标记和可视化上下文。有些信息可以从翻译文件中提取,有些可以通过编辑额外的字符串信息添加:

直接在翻译界面点击 截图上下文 或 标记 旁的”编辑”图标即可进入此界面。

字符串优先级
2.0 新版功能.
使用 priority
标记可以更改字符串优先级,更高优先级的字符串会更早地被提供以进行翻译。
提示
这可以用于以合乎逻辑的方式编排翻译流程。
参见
翻译标记
2.4 新版功能.
在 3.3 版更改: 之前被称为 Quality checks flags,它不再只配置检查了。
翻译标记的默认设置由翻译 组件配置 和翻译文件来决定。然而,你会想要用它来定制每个源字符串。
解释
在 4.1 版更改: 在以前的版本中这被称为 Extra context。
使用解释来阐明翻译的范围或翻译的用法。您可以使用 Markdown 语法来包含链接和其它标记。
字符串的可视化上下文
2.9 新版功能.
你可以将显示你程序中使用的给定源字符串的截屏上传。这帮助译者理解它用在哪里,并且应该如何翻译。
上传的截屏显示在翻译上下文侧栏中:

除了 源字符串另外的信息,截图在 Tools 菜单下有个单独的管理界面。上传截图,将它们手动分配给源字符串,或者使用光学字符识别(OCR)来进行。
上传截图后,就可以在这个界面进行管理以及和源字符串的关联:

检查并修正
定制的自动修正
还可以应用除了自动修正以外自己的自动修正,并将它们包括到 AUTOFIX_LIST
。
自动修复很强大,但可能导致损坏;写脚本的时候要小心。
例如,后面的自动修复会将每次出现的字符串 foo
在翻译中替换为 bar
:
#
# 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/>.
#
from django.utils.translation import gettext_lazy as _
from weblate.trans.autofixes.base import AutoFix
class ReplaceFooWithBar(AutoFix):
"""Replace foo with bar."""
name = _("Foobar")
def fix_single_target(self, target, source, unit):
if "foo" in target:
return target.replace("foo", "bar"), True
return target, False
为了安装定制的检查,在 AUTOFIX_LIST
中为 Python 类提供完全合规的路径,请参见 定制的质量检查、插件和自动修复 。
使用标记定制行为
您可以为每个源字符串(在源字符串复查中,请参见 源字符串另外的信息)或在 component`(:ref:`component-check_flags)中微调 Weblate 的行为(主要是检查)。某些文件格式还允许直接在格式中指定标记(请参见 支持的文件格式)。
标记用逗号分隔,参数用冒号分隔。可以在字符串中使用引号来包含空白字符或特定字符。例如:
placeholders:"special:value":"other value", regex:.*
以下是目前接受的标记列表:
rst-text
将文本视为 reStructuredText 文档,影响 未更改的翻译 。
dos-eol
使用 DOS 的行尾标记,而不使用 Unix 的(使用
\r\n
而不使用\n
)。read-only
这个字符串是只读的,且不应该在 Weblate 中进行编辑。请参见 只读字符串。
priority:N
字符串的优先级。高优先级的字符串首先出现被翻译。默认的优先级是 100 ,字符串的优先级越高,就会越早安排翻译。
max-length:N
将字符串的最大长度限制为 N 个字符,请参见 译文最大长度。
xml-text
font-family:NAME
定义 font-family 来提供检查,请参见 管理字型 。
font-weight:WEIGHT
定义 font-weight 来提供检查,请参见 管理字型 。
font-size:SIZE
定义 font-size 来提供检查,请参见 管理字型 。
font-spacing:SPACING
定义渲染检查的字母间隔,请参见 管理字型 。
icu-flags:FLAGS
指定自定义 ICU MessageFormat 质量检查行为的标记。
icu-tag-prefix:PREFIX
为 ICU MessageFormat 质量检查设置必需的 XML 标签前缀。
placeholders:NAME:NAME2:...
译文中需要的占位符字符串,请参见 占位符。
replacements:FROM:TO:FROM2:TO2...
当检查结果文本参数时执行替换(例如在 最大翻译大小 或 译文最大长度 中)。这一典型应用的情况拓展了非译元素,确保匹配那些即使使用了长值的文本,例如
replacements:%s:"John Doe"
。variants:SOURCE
将此字符串标记为具有匹配源的字符串的变体。见 字符串变体。
regex:REGEX
用于匹配翻译文件的正则表达式,详见 正则表达式 。
forbidden
表示术语表中的禁止翻译,参见 禁止的翻译。
strict-same
使“未更改的译文”检查不使用内置单词黑名单。请参见 未更改的翻译。
check-glossary
启用 不遵循术语表 质量检查。
angularjs-format
启用 AngularJS 插值字符串 质量检查。
c-format
启用 C 格式 质量检查。
c-sharp-format
启用 C# 格式 质量检查。
es-format
启用 ECMAScript 模板文字 质量检查。
i18next-interpolation
启用 i18next 插值 质量检查。
icu-message-format
启用 ICU MessageFormat 质量检查。
java-format
启用 Java 格式 质量检查。
java-messageformat
启用 Java MessageFormat 质量检查。
javascript-format
启用 JavaScript 格式 质量检查。
lua-format
启用 Lua 格式 质量检查。
object-pascal-format
启用 Object Pascal 格式 质量检查。
percent-placeholders
启用 百分比占位符 质量检查。
perl-format
启用 Perl 格式 质量检查。
php-format
启用 PHP 格式 质量检查。
python-brace-format
启用 Python brace 格式 质量检查。
python-format
启用 Python 格式 质量检查。
qt-format
启用 Qt 格式 质量检查。
qt-plural-format
启用 Qt 复数格式 质量检查。
ruby-format
启用 Ruby 格式 质量检查。
scheme-format
启用 Scheme 格式 质量检查。
vue-format
启用 Vue I18n 格式化 质量检查。
md-text
将文本看作 Markdown 文档。启用 Markdown 链接, Markdown 引用, 和 Markdown 语法 质量检查。
safe-html
启用 不安全的 HTML 网站 质量检查。
url
字符串应该只由一个 URL 组成。启用 URL 质量检查。
ignore-bbcode
跳过 BBcode 标记 质量检查。
ignore-duplicate
跳过 连续重复的单词 质量检查。
ignore-check-glossary
跳过 不遵循术语表 质量检查。
ignore-double-space
跳过 双空格 质量检查。
ignore-angularjs-format
跳过 AngularJS 插值字符串 质量检查。
ignore-c-format
跳过 C 格式 质量检查。
ignore-c-sharp-format
跳过 C# 格式 质量检查。
ignore-es-format
跳过 ECMAScript 模板文字 质量检查。
ignore-i18next-interpolation
跳过 i18next 插值 质量检查。
ignore-icu-message-format
跳过 ICU MessageFormat 质量检查。
ignore-java-format
跳过 Java 格式 质量检查。
ignore-java-messageformat
跳过 Java MessageFormat 质量检查。
ignore-javascript-format
跳过 JavaScript 格式 质量检查。
ignore-lua-format
跳过 Lua 格式 质量检查。
ignore-object-pascal-format
跳过 Object Pascal 格式 质量检查。
ignore-percent-placeholders
跳过 百分比占位符 质量检查。
ignore-perl-format
跳过 Perl 格式 质量检查。
ignore-php-format
跳过 PHP 格式 质量检查。
ignore-python-brace-format
跳过 Python brace 格式 质量检查。
ignore-python-format
跳过 Python 格式 质量检查。
ignore-qt-format
跳过 Qt 格式 质量检查。
ignore-qt-plural-format
跳过 Qt 复数格式 质量检查。
ignore-ruby-format
跳过 Ruby 格式 质量检查。
ignore-scheme-format
跳过 Scheme 格式 质量检查。
ignore-vue-format
跳过 Vue I18n 格式化 质量检查。
ignore-translated
跳过 曾被翻译过 质量检查。
ignore-inconsistent
跳过 不一致的 质量检查。
ignore-kashida
跳过 使用了 Kashida 字母 质量检查。
ignore-md-link
跳过 Markdown 链接 质量检查。
ignore-md-reflink
跳过 Markdown 引用 质量检查。
ignore-md-syntax
跳过 Markdown 语法 质量检查。
ignore-max-length
跳过 译文最大长度 质量检查。
ignore-max-size
跳过 最大翻译大小 质量检查。
ignore-escaped-newline
跳过 不匹配的 \n 质量检查。
ignore-end-colon
跳过 不匹配的冒号 质量检查。
ignore-end-ellipsis
跳过 不匹配的省略号 质量检查。
ignore-end-exclamation
跳过 不匹配的感叹号 质量检查。
ignore-end-stop
跳过 不匹配的句号 质量检查。
ignore-end-question
跳过 不匹配的问号 质量检查。
ignore-end-semicolon
跳过 不匹配的分号 质量检查。
ignore-newline-count
跳过 不匹配的换行符 质量检查。
ignore-plurals
跳过 缺少复数形式 质量检查。
ignore-placeholders
跳过 占位符 质量检查。
ignore-punctuation-spacing
跳过 标点间距 质量检查。
ignore-regex
跳过 正则表达式 质量检查。
ignore-same-plurals
跳过 相同复数 质量检查。
ignore-begin-newline
跳过 换行符开头 质量检查。
ignore-begin-space
跳过 空格开头 质量检查。
ignore-end-newline
跳过 换行符结尾 质量检查。
ignore-end-space
跳过 空格结尾 质量检查。
ignore-same
跳过 未更改的翻译 质量检查。
ignore-safe-html
跳过 不安全的 HTML 网站 质量检查。
ignore-url
跳过 URL 质量检查。
ignore-xml-tags
跳过 XML 标记 质量检查。
ignore-xml-invalid
跳过 XML 语法 质量检查。
ignore-zero-width-space
跳过 零宽空格 质量检查。
ignore-ellipsis
跳过 省略号 质量检查。
ignore-icu-message-format-syntax
跳过 ICU MessageFormat 语法 质量检查。
ignore-long-untranslated
跳过 长期未翻译 质量检查。
ignore-multiple-failures
跳过 多项未通过的检查 质量检查。
ignore-unnamed-format
跳过 多个未命名的变量 质量检查。
ignore-optional-plural
跳过 未复数化 质量检查。
注解
通常,对于任何检查,都可以使用标识符将规则命名为 ignore-*
,所以您甚至可以将其用于自定义检查。
每个源字符串的设置,在 组件配置 设置中,并且在翻译文件自身中(例如在 GNU gettex 中),能够理解这些标记。
强制检查
3.11 新版功能.
你可以通过在 组件配置 中设置 强制检查,来配置一个不能忽略的检查列表。列出的每个检查在用户界面中都不能忽略,并且任何未通过检查的字符串都会被标记为 Needs editing (请参见 翻译状态)。
管理字型
3.7 新版功能.
提示
Fonts uploaded into Weblate are used purely for purposes of the 最大翻译大小 check, they do not have an effect in Weblate user interface.
用于计算所呈现文本尺寸的 最大翻译大小 检查需要将字体加载到 Weblate 中,并使用翻译标记选中(请参见 使用标记定制行为)。
在您的翻译项目 Manage 菜单下 Fonts 中的 Weblate 字体管理工具提供了上传和管理字体的界面。可以上传 TrueType 或 OpenType 字体,设置 font-groups 并在检查中使用它们。
字型组允许为不同语言确定不同字型,这是非拉丁语言中典型需要的:

字型组通过名称识别,名称不能包含空白字符或特殊字符,这使它能够容易地用在检查定义中:

字型族和样式在上传后自动识别:

可以将几种字型加载到 Weblate 中:

为了使用字型来检查字符串长度,将适当的标记传递给它 (请参见 使用标记定制行为)。可能会需要后面这些:
max-size:500
指定以像素为单位的最大宽度。
font-family:ubuntu
确定字型组,通过指定其识别文字来使用。
font-size:22
指定以像素为单位的字体大小。
编写自己的检查
Weblate 内置了多种多样的质量检查,(请参阅 质量检查),尽管它们可能没有涵盖您想要检查的所有东西。可以使用 CHECK_LIST
来调整执行的检查列表,也可以添加自定义检查。
子类 weblate.checks.Check
设置一些属性。
应用
check
(如果想要处理代码中的复数的话)或check_single
方法(它将为你完成)。
一些例子:
为了安装定制的检查,在 CHECK_LIST
中为 Python 类提供完全合格的路径,请参见 定制的质量检查、插件和自动修复。
检查翻译文本是否包含“foo”
这是非常简单的检查,只检查翻译中是否丢失了字符串“ foo ”。
#
# 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/>.
#
"""Simple quality check example."""
from django.utils.translation import gettext_lazy as _
from weblate.checks.base import TargetCheck
class FooCheck(TargetCheck):
# Used as identifier for check, should be unique
# Has to be shorter than 50 characters
check_id = "foo"
# Short name used to display failing check
name = _("Foo check")
# Description for failing check
description = _("Your translation is foo")
# Real check code
def check_single(self, source, target, unit):
return "foo" in target
检查捷克语翻译文本的复数差异
使用语言信息检查,验证捷克语中的两种复数形式不同。
#
# 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/>.
#
"""Quality check example for Czech plurals."""
from django.utils.translation import gettext_lazy as _
from weblate.checks.base import TargetCheck
class PluralCzechCheck(TargetCheck):
# Used as identifier for check, should be unique
# Has to be shorter than 50 characters
check_id = "foo"
# Short name used to display failing check
name = _("Foo check")
# Description for failing check
description = _("Your translation is foo")
# Real check code
def check_target_unit(self, sources, targets, unit):
if self.is_language(unit, ("cs",)):
return targets[1] == targets[2]
return False
def check_single(self, source, target, unit):
"""We don't check target strings here."""
return False
机器翻译
内建了几种及其翻译服务的支持,并且每一个可以由管理员使用 MT_SERVICES
来打开。它们受到自己的使用条款约束,因此请确认允许您以所需要的方式来使用它。
源语言可以在 项目配置 中进行配置。
amaGama
由 Virtaal 作者运行的 tmserver 的特殊安装。
通过将 weblate.machinery.tmserver.AmagamaTranslation
添加到 MT_SERVICES
来打开这个服务。
Apertium
一个自由软件机器翻译平台,提供有限语言的翻译。
使用 Apertium的推荐方式是运行您自己的 Apertium-APy 服务器 。
通过将``weblate.machinery.apertium.ApertiumAPYTranslation`` 添加到 MT_SERVICES
中,并设置 MT_APERTIUM_APY
来打开这项服务。
AWS
3.1 新版功能.
Amazon Translate 是神经机器翻译服务,用于将英语与广泛支持的语言进行互译。
通过将
weblate.machinery.aws.AWSTranslation
添加到MT_SERVICES
来打开这项服务。安装 boto3 模块。
配置 Weblate 。
Baidu API 机器翻译
3.2 新版功能.
由百度提供的机器翻译服务。
这项服务使用 API ,并且您需要从百度获得 ID 和 API 密钥来使用它。
通过将 weblate.machinery.baidu.BaiduTranslation
添加到 MT_SERVICES
并设置 MT_BAIDU_ID
和 MT_BAIDU_SECRET
来打开这项服务。
DeepL
2.20 新版功能.
DeepL 是付费服务,提供一些语言的良好机器翻译。您需要购买 DeepL API 订阅,或者您可以使用传统的 DeepL Pro (classic) 计划。
通过将 weblate.machinery.deepl.DeepLTranslation
添加到 MT_SERVICES
,并设置 MT_DEEPL_KEY
来打开这项服务。
提示
如果你有一个计算机辅助翻译工具(CAT )订阅,你应该使用”v1 API”,而不是 Weblate 默认使用的”v2”(在这种情况下,这不是真正的 API 版本)。如果你使用的是免费计划而不是付费计划,你必须使用 https://api-free.deepl.com/
而不是 https://api.deepl.com/
你可以通过 MT_DEEPL_API_URL
来调整它们的参数。
LibreTranslate
4.7.1 新版功能.
LibreTranslate 是一项免费的开源机器翻译服务。公共实例需要 API 密钥,但 LibreTranslate 可以自托管,并且有几个镜像可以免费使用 API。
通过将 weblate.machinery.libretranslate.LibreTranslateTranslation
添加到 MT_SERVICES
并设置 MT_LIBRETRANSLATE_API_URL
来打开这项服务。如果实例需要 API 密钥,你也必须设置 MT_LIBRETRANSLATE_KEY
。
Glosbe
几乎每一种活语言的免费字典与翻译服务。
API 免费使用,但受到使用数据源许可的约束。一段时期有少量来自一个 IP 的呼叫,防止侵权。
通过将 weblate.machinery.glosbe.GlosbeTranslation
添加到 MT_SERVICES
来打开这项服务。
参见
谷歌翻译
Google 提供的机器翻译服务。
这项服务使用了 Google Translation API ,您需要得到 API 密钥,并在 Google API 控制台打开记费。
将 weblate.machinery.google.GoogleTranslation
添加到 MT_SERVICES
,并设置 MT_GOOGLE_KEY
来打开这项服务。
参见
Google Translate API V3 (高级版)
Google 云服务提供的机器翻译服务。
这项服务在如何进行身份验证方面不同于前面的服务。将 weblate.machinery.googlev3.GoogleV3Translation
添加到 MT_SERVICES
,并通过后面的设置来允许服务
如果 location 失败,您还需要指定 MT_GOOGLE_LOCATION
。
微软认知服务翻译工具
2.10 新版功能.
由 Microsoft 在 Azure 门户提供的机器翻译服务,作为 Cognitive Services 的一种。
Weblate 使用了 Translator API V3。
为了允许这项服务,将 weblate.machinery.microsoft.MicrosoftCognitiveTranslation
添加到 MT_SERVICES
,并设置 MT_MICROSOFT_COGNITIVE_KEY
。
Translator Text API V2
您在 Translator API V2 使用的密钥可以在 API 3 中使用。
Translator Text API V3
您需要在 Azure 门户注册,并使用得到的密钥。关于新的 Azure 密钥,您还需要设置 MT_MICROSOFT_REGION
为您的服务设置地区。
微软术语服务
2.19 新版功能.
Microsoft Terminology Service API 允许您通过 Web 服务,可编程地访问 Langurage Portal 上可用的术语、定义和用户界面( UI )字符串。
通过将 weblate.machinery.microsoftterminology.MicrosoftTerminologyService
添加到 MT_SERVICES
来打开这项服务。
参见
ModernMT
4.2 新版功能.
通过将 weblate.machinery.modernmt.ModernMTTranslation
添加到 MT_SERVICES
,并配置 MT_MODERNMT_KEY
来打开这项服务。
MyMemory
使用机器翻译的巨量翻译记忆库。
自由匿名使用,当前限制为 100 个请求/天,或者在 MT_MYMEMORY_EMAIL
中提供电子邮箱联系地址时限制为 1000 个请求/天。您还可以向他们请求更多。
通过将 weblate.machinery.mymemory.MyMemoryTranslation
添加到 MT_SERVICES
,并设置 MT_MYMEMORY_EMAIL
来打开这项服务。
网易见外 API 机器翻译
3.3 新版功能.
网易提供的机器翻译服务。
这项服务使用 API ,您需要从网易获取密钥和密码。
通过将 weblate.machinery.youdao.NeteaseSightTranslation
添加到 MT_SERVICES
并设置 MT_NETEASE_KEY
和 MT_NETEASE_SECRET
来打开这项服务。
tmserver
您可以通过使用 Translate-toolkit 绑定的一个服务器并与之对话,来运行您自己的翻译服务器。您还可以将它与 amaGama 服务器一起使用,它是 tmserver 的增强版本。
首先您会想要将一些数据导入翻译记忆库:
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
启动 tmserver 来收听您的请求:
tmserver -d /var/lib/tm/db
配置 Weblate 来与之对话:
MT_TMSERVER = "http://localhost:8888/tmserver/"
Yandex 翻译
Yandex 提供的机器翻译服务。
这项服务使用翻译 API ,您需要从 Yandex 得到 API 密钥。
通过将 weblate.machinery.yandex.YandexTranslation
添加到 MT_SERVICES
,并设置 MT_YANDEX_KEY
来打开这项服务。
有道智云 API 机器翻译
3.2 新版功能.
有道提供的机器翻译服务。
这项服务使用 API ,您需要从有道获得 ID 和 API 密钥。
通过将 weblate.machinery.youdao.YoudaoTranslation
添加到 MT_SERVICES
,并设置 MT_YOUDAO_ID
和 MT_YOUDAO_SECRET
来打开这项服务。
Weblate
Weblate 也可以是机器翻译的来源。它基于 Woosh 全文引擎,并提供精确和不精确的匹配。
通过将 weblate.machinery.weblatetm.WeblateTranslation
添加到 MT_SERVICES
来打开这项服务。
Weblate 翻译记忆库
2.20 新版功能.
翻译记忆库 也可以用作机器翻译建议的来源。
通过将 weblate.memory.machine.WeblateMemory
添加到 MT_SERVICES
,来打开这项服务。这项服务默认打开。
SAP 翻译中心
SAP 提供的机器翻一下服务。
你需要有 SAP 账户(且 SAP Cloud Platform 中 SAP Translation Hub 已启用 )来使用这项服务。
通过将 weblate.machinery.saptranslationhub.SAPTranslationHub
添加到 MT_SERVICES
,并设置对沙箱或生产 API 的适当访问,来打开这项服务。
注解
为了访问 Sandbox API ,您需要设置 MT_SAP_BASE_URL
和 MT_SAP_SANDBOX_APIKEY
。
为了访问生产 API ,您需要设置 MT_SAP_BASE_URL
、 MT_SAP_USERNAME
和 MT_SAP_PASSWORD
。
定制化的机器翻译
您还可以用几行 Python 代码来实现自己的机器翻译服务。此示例使用 dictionary
Python 模块实现了一组确定的语言的机器翻译:
#
# 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}
你可以在 MT_SERVICES
中列出自己的类,Weblate 就会开始使用它了。
附加组件
2.19 新版功能.
附加组件提供了自定义和自动化翻译工作流程的方法。管理员可以从每个相应翻译组件的 Manage ↓ Addons 菜单添加和管理附加组件。
提示
您也可以使用 API、 DEFAULT_ADDONS
或 install_addon
来配置插件。

内置附加组件
自动化翻译
3.9 新版功能.
- 附加组件 ID
weblate.autotranslate.autotranslate
- 配置
mode
自动翻译模式
可用选项:
suggest
– 添加为建议translate
– 添加为翻译fuzzy
– 添加为需要编辑filter_type
搜索筛选器
可用选项:
all
– 所有字符串nottranslated
– 未翻译的字符串todo
– 需要处理的字符串fuzzy
– 标记为需要编辑的字符串check:inconsistent
– 未通过的检查:不一致auto_source
自动翻译的来源
可用选项:
others
– 其他翻译组件mt
– 机器翻译component
组件
输入要用作来源的组件,留空则使用当前项目中的所有组件。
engines
机器翻译引擎
threshold
匹配分数阈值
- 触发器
组件更新,每天
使用机器翻译或其他组件自动翻译字符串。
触发条件:
当组件中出现新字符串时。
每个组件每个月一次,可以使用
BACKGROUND_TASKS
进行配置。
JavaScript 本地化 CDN
4.2 新版功能.
- 附加组件 ID
weblate.cdn.cdnjs
- 配置
threshold
翻译阈值
包含的翻译的阈值。
css_selector
CSS选择器
检测可本地化元素的CSS选择器。
cookie_name
语言cookie名称
存储语言选项的cookie的名称。
files
从 HTML 文件里提取字符串
用于解析可翻译字符串的当前存储库中的文件名或远程URLs的列表。
- 触发器
每日,代码库提交后,代码库更新后
将译文发布到内容交付网络,以便在 JavaScript或 HTML 本地化中使用。
可以用于本地化静态 HTML 网页,或者在 JavaScript 代码中加载本地化文件。
为你的组件生成一个唯一的 URL,你可以将其包含在 HTML 页面中以本地化它们。详情见 使用 Weblate CDN 翻译 HTML 和 JavaScript。
移除空白字符串
4.4 新版功能.
- 附加组件 ID
weblate.cleanup.blank
- 配置
此附加组件无配置.
- 触发器
代码库提交后,代码库更新后
从翻译文件中删除没有翻译的字符串.
使用此方法可以使翻译文件中不存在任何空字符串(例如,如果你的本地化库将它们显示为缺失,而不是退回到源字符串)。
清理翻译文件
- 附加组件 ID
weblate.cleanup.generic
- 配置
此附加组件无配置.
- 触发器
代码库提交前,代码库更新后
更新所有翻译文件以匹配单语言译文模版文件。对于大多数文件格式来说,这意味着移除译文模版文件中不再出现的旧翻译条目。
添加缺少的语言
- 附加组件 ID
weblate.consistency.languages
- 配置
此附加组件无配置.
- 触发器
每天,添加代码库后
确保对一个项目内所有组件使用一致的一组语言。
每隔 24 小时,和在 Weblate 中加入新语言时,会检查一次缺失的语言。
不像其他多数附加组件,这个附加组件影响整个项目。
提示
用 自动化翻译 自动翻译新添加的字符串。
组件发现
- 附加组件 ID
weblate.discovery.discovery
- 配置
match
用于匹配翻译文件的正则表达式
file_format
文件格式
name_template
自定义组件名称
base_file_template
指定单语种译文模版文件名
保持双语翻译文件空白。
new_base_template
为新的翻译条目指定译文模版文件
用于创建新翻译的文件名。对于 gettext 格式,请选择 .pot 文件。
language_regex
语言筛选
扫描文件掩码时用于筛选翻译文件的正则表达式。
copy_addons
把来自主组件的附加组件克隆到新创建的组件
remove
删除不存在文件的组件
confirm
我确认上述匹配是正确的
- 触发器
代码库更新后
根据版本控制系统中文件更改的情况来自动添加或删除项目的组件.
每次更新 VCS 时触发,在其他方面类似 import_project
管理命令。通过这种方式,你可以在一个 VCS 中跟踪多个翻译组件。
该匹配是使用允许复杂配置的正则表达式完成的,但这样做需要一些知识。一些常见用例的例子可以在附加组件帮助部分找到。
点击 Save 后,将显示匹配组件的预览,您可以从中检查配置是否真正符合您的需求:

提示
Component discovery add-on uses Weblate internal URLs. It’s a convenient way to share
VCS setup between multiple components. Linked components use the local repository of
the main component set up by filling weblate://project/main-component
into the 源代码库 field (in Manage ↓ Settings ↓
Version control system) of each respective component.
This saves time with configuration and system resources too.
参见
批量编辑
3.11 新版功能.
- 附加组件 ID
weblate.flags.bulk
- 配置
q
查询
state
要设置的状态
可用选项:
-1
– 不要更改10
– 需要编辑20
– 已翻译30
– 已审核add_flags
要添加的翻译标记
remove_flags
要删除的翻译标记
add_labels
要添加的标签
remove_labels
要删除的标签
- 触发器
组件更新
批量编辑标记、标签或字符串状态。
自动化添加标签,从搜索查询 NOT has:label
开始,然后给搜索查询所得字符串添加标签,直到所有字符串都有所需的标签。还可以对 Weblate 元数据进行其他自动化操作。
例子:
搜索查询 |
|
---|---|
要添加的标签 |
近期 |
搜索查询 |
|
---|---|
要添加的翻译标记 |
|
将未更改的译文标记为“需要编辑”
3.1 新版功能.
- 附加组件 ID
weblate.flags.same_edit
- 配置
此附加组件无配置.
- 触发器
unit post-create
每当从 VCS 导入新的可翻译字符串并与源字符串匹配时,就会在 Weblate 中标记为需要编辑。对于包含未翻译字符串的源字符串的文件格式尤其有用。
参见
将新的源字符串标记为“需要编辑”
- 附加组件 ID
weblate.flags.source_edit
- 配置
此附加组件无配置.
- 触发器
unit post-create
每当一个新的源字符串从版本控制系统(VCS)中导入时,它将在 Weblate 中被标记为需要编辑。这样就可以简单地筛选并编辑开发者编写的源字符串。
参见
将导入的新译文标记为“需要编辑”
- 附加组件 ID
weblate.flags.target_edit
- 配置
此附加组件无配置.
- 触发器
unit post-create
每当一个新的可翻译字符串从版本控制系统(VCS)中导入时,它将在 Weblate 中被标记为需要编辑。这样就可以简单地筛选并编辑开发者创建的翻译。
参见
统计数据生成器
- 附加组件 ID
weblate.generate.generate
- 配置
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 }}", }
参见
假语言环境 (Pseudolocale)生成
- 附加组件 ID
weblate.generate.pseudolocale
- 配置
source
源字符串
target
目标翻译
prefix
字符串前缀
suffix
字符串后缀
- 触发器
组件更新,每天
通过向源字符串添加前缀和后缀自动生成翻译。
伪 locale 对于查找未准备好进行本地化的字符串很有用。这是通过修改所有可翻译的源字符串来实现的,使得在用伪 locale 语言运行应用程序时很容易发现未修改的字符串。
也可以查找其本地化对应项可能不适合布局的字符串。
提示
可以使用真正的语言进行检测,但在 Weblate 中有专用的假语言环境——en_XA 和 ar_XB。
提示
You can use this add-on to start translation to a new locale of an existing language or similar language. Once you add the translation to the component, follow to the add-on. Example: If you have fr and want to start fr_CA translation, simply set fr as the source, fr_CA as the target, and leave the prefix and suffix blank.
一旦您有新的翻译填重,请卸载插件,以防止 Weblate 更改复制后的翻译。
在注释中添加贡献信息
- 附加组件 ID
weblate.gettext.authors
- 配置
此附加组件无配置.
- 触发器
代码库预提交
更新 PO 文件头的注释部分,以包含贡献者姓名和贡献年份。
PO 文件头看上去是这样的:
# 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.
更新“配置文件”中的 ALL_LINGUAS 变量
- 附加组件 ID
weblate.gettext.configure
- 配置
此附加组件无配置.
- 触发器
添加代码库后,每天
当新的翻译添加时,更新 configure
、 configure.in
或任何 configure.ac
文件中的 ALL_LINGUAS 变量。
自定义 gettext 输出
- 附加组件 ID
weblate.gettext.customize
- 配置
width
自动换行
默认情况下 gettext 会在每行第 77 个字符处与换行符处换行。添加 –no-wrap 参数后,换行只在换行符处发生。
可用选项:
77
– 在 77 个字符处和换行符处换行65535
– 仅在换行符处换行-1
– 不换行- 触发器
storage post-load
允许自定义 gettext 的输出行为,例如是否启用自动换行。
它提供以下选项:
在 77 个字符处和新一行时来换行
仅在换行符处折行
不换行
注解
默认情况下 gettext 会在每行第 77 个字符处与换行符处换行。添加 --no-wrap
参数后,换行只会在换行符处发生。
更新 LINGUAS 文件
- 附加组件 ID
weblate.gettext.linguas
- 配置
此附加组件无配置.
- 触发器
添加代码库后,每天
添加新的翻译时更新 LINGUAS 文件。
生成 MO 文件
- 附加组件 ID
weblate.gettext.mo
- 配置
path
生成的 MO 文件的路径
如未指定,将使用 PO 文件对应的位置。
- 触发器
代码库预提交
为每个变更的 PO 文件自动生成 MO 文件。
生成的 MO 文件的位置可以定制化,并且其字段使用 模板标记。
更新 PO 文件以匹配 POT 文件 (msgmerge)
- 附加组件 ID
weblate.gettext.msgmerge
- 配置
previous
保持已翻译字符串先前的 msgids
no_location
删除翻译字符串的位置
fuzzy
使用模糊匹配
- 触发器
代码库更新后
使用 msgmerge 来更新所有的 PO 文件(如 文件掩码 所配置),而与 POT 文件(如 新翻译的译文模版 所配置)匹配。
每当从上游存储库中提取新的更改时都会被触发。多数 msgmerge 命令行选项可通过附加组件配置进行设置。
压缩(Squash) Git 提交
- 附加组件 ID
weblate.git.squash
- 配置
squash
提交汇并
可用选项:
all
– 所有提交并成一个提交language
– 根据语言file
– Per fileauthor
– Per authorappend_trailers
为压缩提交增加额外信息
额外信息是看起来类似于 RFC 822 电子邮件标头,位于提交消息的其他自由格式部分的末尾,例如 “Co-authored-by…’.。
commit_message
提交信息
将使用此提交消息代替来自压缩提交的组合提交消息。
- 触发器
代码库提交后
推送变更之前压缩(Squash) Git 提交。
以下模式之一中,Git提交可以在推送更改之前被压缩:
所有提交成一个
每种语言
每个文件
每位作者
原始提交信息保留,但其作者信息丢失,除非选择 Per author ,或者定制提交信息来包括它。
可以选择使用自定义提交消息覆盖原始提交消息。消息选项见 模板标记。
额外信息(提交行像 Co-authored-by: …
)可选地从原始提交信息中去掉,并且添加在去掉的提交信息后面。这还可以为每一位翻译者产生适当的 Co-authored-by:
信誉。
自定义 JSON 输出
- 附加组件 ID
weblate.json.customize
- 配置
sort_keys
对 JSON 键值排序
indent
JSON 缩进
style
JSON 缩进风格
可用选项:
spaces
– 空格tabs
– 制表符- 触发器
storage post-load
允许调整 JSON 的输出行为,例如缩进或排序。
格式化 Java 属性文件
- 附加组件 ID
weblate.properties.sort
- 配置
此附加组件无配置.
- 触发器
代码库预提交
排序 Java 属性文件。
陈旧评论删除
3.7 新版功能.
- 附加组件 ID
weblate.removal.comments
- 配置
age
要保持的天数
- 触发器
每天
设置删除评论的时间。
这可以用于删除可能已经过时的陈旧评论。小心使用,因为评论变旧并不意味着它们已经失去了重要性。
陈旧建议删除
3.7 新版功能.
- 附加组件 ID
weblate.removal.suggestions
- 配置
age
要保持的天数
votes
投票阈值
移除阈值。当投票被禁用时该项无效果。
- 触发器
每天
设置删除建议的时间。
此附加组件在与建议投票一道用来删除在给定的时间内没有得到足够的正面投票的建议方面非常有用。
更新 RESX 文件
3.9 新版功能.
- 附加组件 ID
weblate.resx.update
- 配置
此附加组件无配置.
- 触发器
代码库更新后
更新所有翻译文件以匹配上游单语言译文模版文件。未使用的字符串将被删除,新字符串将复制源字符串添加。
提示
如果只想删除陈旧的翻译键,那么使用 清理翻译文件。
自定义 YAML 输出
3.10.2 新版功能.
- 附加组件 ID
weblate.yaml.customize
- 配置
indent
YAML 缩进
width
自动换行
可用选项:
80
– 在 80 个字符处换行100
– 在 100 个字符处换行120
– 在 120 个字符处换行180
–在 180 个字符处换行65535
– 不换行line_break
换行符
可用选项:
dos
– DOS (\r\n)unix
– UNIX (\n)mac
– MAC (\r)- 触发器
storage post-load
允许调整 YAML 的输出,例如自定义缩进或自定义换行。
定制附加组件列表
附加组件列表由 WEBLATE_ADDONS
配置。要添加其他附加组件,只需在这个设置中包含绝对类名称即可。
编写附加组件
你也可以编写自己的附加组件,创建一个 :class:`weblate.addons.base.BaseAddon`的子类来定义附加组件元数据,然后实现一个回调来执行处理。
参见
从附加组件执行脚本
附加组件还可以用于执行外部脚本。这曾经集成在 Weblate 中,但现在必须写一些代码,将脚本包裹在附加组件中。
#
# 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/>.
#
"""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"
安装方法请参见 定制的质量检查、插件和自动修复 。
对于任何给定的组件,当前路径设置为版本控制系统(VCS)仓库的根目录时,执行脚本。
此外,以下环境变量是可用的:
- WL_VCS
使用的版本控制系统。
- WL_REPO
上游仓库 URL 。
- WL_PATH
版本控制系统(VCS)仓库的绝对路径。
- WL_BRANCH
2.11 新版功能.
当前组件配置的仓库分支。
- WL_FILEMASK
当前组件的文件掩码。
- WL_TEMPLATE
单语言翻译模板的文件名(可以为空)。
- WL_NEW_BASE
2.14 新版功能.
建立新的翻译所使用文件的文件名(可以为空)。
- WL_FILE_FORMAT
用于当前组件的文件格式。
- WL_LANGUAGE
当前处理的翻译的语言(对于组件级别的钩子不可用)。
- WL_PREVIOUS_HEAD
更新后的上个 HEAD (仅在运行更新后钩子后可用)。
- WL_COMPONENT_SLUG
3.9 新版功能.
组件标识串用于构建 URL 。
- WL_PROJECT_SLUG
3.9 新版功能.
项目标识串用于构建 URL 。
- WL_COMPONENT_NAME
3.9 新版功能.
组件名称。
- WL_PROJECT_NAME
3.9 新版功能.
项目名称。
- WL_COMPONENT_URL
3.9 新版功能.
组件 URL 。
- WL_ENGAGE_URL
3.9 新版功能.
项目参与 URL 。
参见
更新后存储库处理
可用于在 VCS 上游源更改时更新翻译文件。为了实现这个功能,请记住 Weblate 只能看到提交给版本控制系统(VCS)的文件,所以您需要将更改作为脚本的一部分提交。
例如,使用 Gulp,您可以使用以下代码来实现:
#! /bin/sh
gulp --gulpfile gulp-i18n-extract.js
git commit -m 'Update source strings' src/languages/en.lang.json
翻译的预提交处理
在将翻译提交到存储库之前,使用 commit 脚本自动更改翻译。
它作为组成当前翻译文件名的单一参数而通过。
翻译记忆库
2.20 新版功能.
Weblate 带有内建的翻译记忆库,包括下面的:
翻译记忆库中的内容可以以两种方式之一来应用:
对于安装提示,请参见 Weblate 翻译记忆库,它默认是打开的。
翻译记忆库的范围
3.2 新版功能: 在较早的版本中,翻译记忆库只能从相应于当前导入的翻译记忆库范围的文件中加载。
翻译记忆库的范围这样允许私有或翻译者共享,来适应所需要的行为。
导入翻译记忆库
使用 import_memory
命令导入任意翻译记忆库数据,使记忆的内容可用于所有的用户和项目。
每名用户的翻译记忆库
在每个单独用户的个人翻译记忆库中自动存储用户的翻译。
每个项目的翻译记忆库
项目内的所有翻译都自动存储在项目翻译记忆库中,这个翻译记忆库只在项目内可用。
管理翻译记忆库
用户界面
3.2 新版功能.
在基本上用户界面上,可以管理每名用户每个项目的项目翻译记忆库。它可以用于下载、消除或导入翻译记忆库。
提示
JSON的翻译记忆库可以导入 Weblate,提供了 TMX 与其他工具进行互操作。

管理界面
有几个管理命令来操作翻译记忆库的内容。它们整体操作翻译记忆库,不会被范围来筛选(除非被参数请求):
dump_memory
将记忆库导入 JSON
import_memory
将 TMX 或 JSON 文件导入翻译记忆库
配置
所有的设置都存储在 settings.py
中(就像 Django 通常那样)。
注解
更改这些设置中的任意一项后,您需要重新启动 Weblate——包括 WSGI 和 Celery 进程。
在它作为 mod_wsgi
运行的情况下,需要重新启动 Apache ,来重新加载配置。
参见
还要请查看 Django’s documentation 中关于配置 Django 自身的参数。
ANONYMOUS_USER_NAME
未登录用户的用户名。
参见
AUDITLOG_EXPIRY
3.6 新版功能.
Weblate 应该将审计日志保存多少天,审计日志包括了账户活动的信息。
默认为 180 天。
AUTH_LOCK_ATTEMPTS
2.14 新版功能.
应用速率限制之前,认证尝试失败的最大次数。
当前,这应用在后面的位置:
登录。删除账户密码,防止用户不请求新的密码而登录。
密码重置。防止发出新的电子邮件,避免向用户发出太多密码重置尝试的垃圾邮件。
默认为 10 。
参见
频次限制 ,
AUTO_UPDATE
3.2 新版功能.
在 3.11 版更改: 更改原来的开关选项,来区别接受哪个字符串。
以每天的频率更新所有仓库。
提示
在不使用 通知钩子 来自动更新 Weblate 仓库的情况下有用。
注解
除了字符串选项还存在开关选项,用于向后兼容。
选项有:
"none"
不进行每日更新。
"remote"
也是False
只进行远程更新。
"full"
也是True
更新远程,并合并工作副本。
注解
这需要 使用 Celery 的后台任务 工作,并在重启后生效。
AVATAR_URL_PREFIX
构成头像 URL 的前缀为: ${AVATAR_URL_PREFIX}/avatar/${MAIL_HASH}?${PARAMS}
。已知后面的服务工作:
- Gravatar (默认),根据 https://gravatar.com/
AVATAR_URL_PREFIX = 'https://www.gravatar.com/'
- Libravatar ,根据 https://www.libravatar.org/
AVATAR_URL_PREFIX = 'https://www.libravatar.org/'
参见
AUTH_TOKEN_VALID
2.14 新版功能.
身份验证令牌和密码重置电子邮件中临时密码的有效时间。以秒为单位,默认为 172800( 2 天)。
AUTH_PASSWORD_DAYS
2.15 新版功能.
应该允许几天来使用相同的密码。
注解
Weblate 2.15 版本之前的密码更改不遵从这个原则。
默认为 180 天。
AUTOFIX_LIST
当存储字符串时应用自动修复列表。
注解
为应用自动修复见面的 Python 类提供完全合规的路径。
可用的修复:
weblate.trans.autofixes.whitespace.SameBookendingWhitespace
将字符串开头和结尾处的空白字符与原文匹配。
weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis
替换连续的点 (…) ,如果源字符串有一个对应的省略号 (…)。
weblate.trans.autofixes.chars.RemoveZeroSpace
如果原文不包含任何零宽空格字符,则删除零宽空格字符。
weblate.trans.autofixes.chars.RemoveControlChars
如果原文不包含任何控制字符,则删除控制字符。
weblate.trans.autofixes.html.BleachHTML
从标记为
safe-html
的字符串中去掉不安全的 HTML 标记( 请参见 不安全的 HTML 网站 )。
可以选择使用哪一个:
AUTOFIX_LIST = (
"weblate.trans.autofixes.whitespace.SameBookendingWhitespace",
"weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis",
)
BACKGROUND_TASKS
4.5.2 新版功能.
Defines how often lengthy maintenance tasks should be triggered for a component.
现在这个控件:
可能的选项:
monthly
(this is the default)weekly
daily
never
注解
Increasing the frequency is not recommended when Weblate contains thousands of components.
BASE_DIR
Weblate 源所在的基本目录。用于默认得到几个其他路径:
默认值:Weblate 源的顶层目录。
BASIC_LANGUAGES
4.4 新版功能.
提供给用户开始新的翻译的语言列表。当未指定时,使用内建列表,其中包括所有常用的语言,但没有特定国家/地区的变体。
这只是限制了非特权用户将不想要的语言添加进来。项目管理员仍然被给出 Weblate 中定义的所有语言选择。
注解
这对 Weblate 并不定义新的语言,它只在数据库中筛选了现有的那些。
示例:
BASIC_LANGUAGES = {"cs", "it", "ja", "en"}
参见
BORG_EXTRA_ARGS
4.9 新版功能.
You can pass additional arguments to borg create when built-in backups are triggered.
示例:
BORG_EXTRA_ARGS = ["--exclude", "vcs/"]
CSP_SCRIPT_SRC, CSP_IMG_SRC, CSP_CONNECT_SRC, CSP_STYLE_SRC, CSP_FONT_SRC
为 Weblate 定制 Content-Security-Policy
标头。根据允许集成的第三方服务(Matomo、Google Analytics、Sentry……)来自动生成标头。
这些默认为空列表。
示例:
# Enable Cloudflare Javascript optimizations
CSP_SCRIPT_SRC = ["ajax.cloudflare.com"]
参见
CHECK_LIST
翻译时执行的质量检查列表。
注解
提供一个实现了检查接口的 Python 类的完全合规路径。
调整检查列表,来包括与你相关的那些检查。
所有内建的 质量检查 默认都打开,可以从那里更改设置。它们在 配置的例子 中被默认注释掉,从而使用默认值。然后每个新的 Weblate 版本执行新的检查。
可以关闭所有检查:
CHECK_LIST = ()
可以只打开一部分检查:
CHECK_LIST = (
"weblate.checks.chars.BeginNewlineCheck",
"weblate.checks.chars.EndNewlineCheck",
"weblate.checks.chars.MaxLengthCheck",
)
注解
更改这些设置只影响新更改的翻译,现存的检查仍然存储在数据库中。为了将更改同样应用到存储的翻译中,运行 updatechecks
。
COMMENT_CLEANUP_DAYS
3.6 新版功能.
在一定天数后删除评论。默认为 None
,意味着不删除。
COMMIT_PENDING_HOURS
2.10 新版功能.
通过后台任务方式提交待定的更改之间的小时数。
参见
CONTACT_FORM
4.6 新版功能.
Configures how e-mail from the contact form is being sent. Choose a configuration that matches your mail server configuration.
"reply-to"
发送者在 Reply-To 中使用,这是默认行为。
"from"
发件人为:mailheader:From, 你的电子邮箱服务器需要允许发送此类邮件。
DATA_DIR
Weblate 存储所有数据的文件夹。它包含指向版本控制系统(VCS)仓库、全文索引和外部工具的各种配置文件。
后面的子目录通常存在:
home
Home 目录用于调用脚本。
ssh
SSH 密钥和配置。
static
静态 Django 文件的默认位置,由
django:STATIC_ROOT`指定。见 :ref:`static-files
。Docker 容器为这个使用了一个单独的卷,请参阅 Docker 容器卷。
media
Django 媒体文件的默认位置,由
django:MEDIA_ROOT`指定。包含已上传的截屏,见 :ref:`screenshots
。vcs
翻译的版本控制仓库。
backups
每日备份数据,详情请查阅 下载的数据用于备份。
celery
Celery 调度程序数据,见 使用 Celery 的后台任务。
fonts
:用户上传的字体,参见 管理字型。
注解
这个目录必须由 Weblate 写入。运行作为 uWSGI 意味着 www-data
用户应该对它具有写入权限。
实现这个的最简单方式是使用户作为目录的所有者:
sudo chown www-data:www-data -R $DATA_DIR
默认到 $BASE_DIR/data
。
参见
DATABASE_BACKUP
3.1 新版功能.
数据库备份应该存储为纯文本,压缩还是跳过。授权值为:
"plain"
"compressed"
"none"
DEFAULT_ACCESS_CONTROL
3.3 新版功能.
新项目的默认访问控制设置:
0
Public
1
Protected
100
Private
200
Custom
如果手动管理 ACL 则使用 Custom ,这意味着不依赖于 Weblate 内部管理。
DEFAULT_AUTO_WATCH
4.5 新版功能.
Configures whether Automatically watch projects on contribution
should be turned on for new users. Defaults to True
.
参见
DEFAULT_RESTRICTED_COMPONENT
4.1 新版功能.
组件限制的默认值。
DEFAULT_ADD_MESSAGE, DEFAULT_ADDON_MESSAGE, DEFAULT_COMMIT_MESSAGE, DEFAULT_DELETE_MESSAGE, DEFAULT_MERGE_MESSAGE
不同操作的默认提交信息,请查阅 组件配置 了解详情。
参见
DEFAULT_ADDONS
安装在每个创建的组件上的默认附加组件。
注解
此设置只影响新创建的组件。
示例:
DEFAULT_ADDONS = {
# Add-on with no parameters
"weblate.flags.target_edit": {},
# Add-on with parameters
"weblate.autotranslate.autotranslate": {
"mode": "suggest",
"filter_type": "todo",
"auto_source": "mt",
"component": "",
"engines": ["weblate-translation-memory"],
"threshold": "80",
},
}
DEFAULT_COMMITER_EMAIL
2.4 新版功能.
提交者电子邮件地址默认为 noreply@weblate.org
。
DEFAULT_COMMITER_NAME
2.4 新版功能.
提交者姓名默认为 Weblate
。
DEFAULT_LANGUAGE
4.3.2 新版功能.
例如在 :ref:`component-source_language`中使用的默认源语言。
默认为 en。匹配的语言对象需要存在于数据库中。
DEFAULT_MERGE_STYLE
3.4 新版功能.
任何新组件的合并风格。
rebase - default
merge
DEFAULT_TRANSLATION_PROPAGATION
2.5 新版功能.
翻译传播的默认设置,默认为 True
。
DEFAULT_PULL_MESSAGE
用于新的拉取请求的标题,默认为 'Update from Weblate'
。
ENABLE_AVATARS
是否为用户打开基于 Gravatar 的头像。默认打开。
头像取出并缓存在从服务器中,降低了泄漏个人信息的风险,加速了用户体验。
参见
ENABLE_HOOKS
是否允许匿名远程钩子。
参见
ENABLE_HTTPS
将链接作为 HTTPS 还是 HTTP 发送给 Weblate。这个设置影响发送电子邮件,并产生绝对 URL。
在默认配置中,这还用于与 HTTPS 相关的几个 Django 设置 — 启用安全cookie、切换 HSTS 或允许重定向到 HTTPS URL。
在一些情况下 HTTPS 重定向会有问题,您可以在使用反向代理进行 SSL 终端连接的情况下碰到无限重定向的问题,使用反向代理进行 SSL 终端连接不能将协议标头正确地传递给 Django。请调整自己的反向代理配置,去掉 X-Forwarded-Proto
或 Forwarded
标头,或者配置 SECURE_PROXY_SSL_HEADER
,让 Django 正确地检测 SSL 状态。
ENABLE_SHARING
打开/关闭 :guilabel: Share 菜单,使用户能够将翻译过程分享到社交网络上。
GET_HELP_URL
4.5.2 新版功能.
可以找到你的 Weblate 实例支持的 URL。
GITLAB_CREDENTIALS
4.3 新版功能.
用于 GitLab 服务器的证明列表。
提示
如果你想要Weblate与它们中的更多进行交互,请使用此功能,对于单一的 GitLab 端点,继续使用 GITLAB_USERNAME
和 GITLAB_TOKEN
。
GITLAB_CREDENTIALS = {
"gitlab.com": {
"username": "weblate",
"token": "your-api-token",
},
"gitlab.example.com": {
"username": "weblate",
"token": "another-api-token",
},
}
GITLAB_USERNAME
GitLab 用户名,用于发送翻译更新的合并请求。
GITLAB_TOKEN
4.3 新版功能.
使用 GitLab 个人访问令牌,用于翻译更新的 API 进行调用。
GITHUB_CREDENTIALS
4.3 新版功能.
用于 GitHub 服务器的证明列表。
提示
在想要 Weblate 与它们中的更多进行交互的情况下,使用这个,对于单一的 GitHub 终点,紧跟 GITHUB_USERNAME
and GITHUB_TOKEN
。
GITHUB_CREDENTIALS = {
"api.github.com": {
"username": "weblate",
"token": "your-api-token",
},
"github.example.com": {
"username": "weblate",
"token": "another-api-token",
},
}
GITHUB_USERNAME
GitHub 用户名,用于发送翻译更新的拉取请求。
GITHUB_TOKEN
4.3 新版功能.
GitHub个人访问令牌,用于进行API调用,来发送翻译更新的拉取请求。
GOOGLE_ANALYTICS_ID
Google Analytics(分析)ID ,开启使用 Google Analytics(分析)对 Weblate 的监测。
HIDE_REPO_CREDENTIALS
隐藏仓库凭据避免出现在 web 界面中。在仓库 URL 带有用户名和密码的情况下, Weblate 会在相关信息显示给用户时将其隐藏起来。
例如,它将显示 https://git.example.com/repo.git
不会显示 https://user:password@git.example.com/repo.git
。它也尝试以相似的方式清除版本控制系统(VCS)错误信息。
注解
默认这是打开的。
HIDE_VERSION
4.3.1 新版功能.
对未经身份验证用户隐藏版本信息。这也会使所有文档链接都指向最新的版本,而不是与当前安装版本相匹配的文档。
一些公司推荐在安全实践上推荐隐藏版本,但不能防止攻击者通过试探性为来找出版本。
注解
默认这是关闭的。
IP_BEHIND_REVERSE_PROXY
2.14 新版功能.
指示 Weblate 是否在反向代理后面运行。
如果设置为 True
, Weblate 会从 :setting:`IP_PROXY_HEADER`定义的标头中得到 IP 地址。
警告
确保真正使用反向代理,并且设置了这个标头,否则用户将能够假冒 IP 地址。
注解
默认这不是打开的。
IP_PROXY_HEADER
2.14 新版功能.
指示当 IP_BEHIND_REVERSE_PROXY
打开时,Weblate应该从那个标头得到 IP 地址。
默认为 HTTP_X_FORWARDED_FOR
。
IP_PROXY_OFFSET
2.14 新版功能.
指示 IP_PROXY_HEADER
的哪部分用作客户端 IP 地址。
取决于你的设置,这个标头会包括几个 IP 地址,(例如 X-Forwarded-For: a, b, client-ip
),并且可以配置标头的哪个地址在这里用作客户端 IP 地址。
警告
设置这个会影响你安装的安全性,应该只配置它来使用信任的代理来确定 IP 地址。
默认为 0 。
LEGAL_URL
3.5 新版功能.
你的 Weblate 实例显示其法律文件的 URL。
提示
在将你的法律文件保存在 Weblate 之外,而将其嵌入 Weblate 的情况下有用。细节请查看 法律声明 。
示例:
LEGAL_URL = "https://weblate.org/terms/"
参见
LICENSE_EXTRA
包括在许可选择中的其他许可。
注解
每个许可的定义应该是其短名称、长名称和 URL 的元组。
例如:
LICENSE_EXTRA = [
(
"AGPL-3.0",
"GNU Affero General Public License v3.0",
"https://www.gnu.org/licenses/agpl-3.0-standalone.html",
),
]
LICENSE_FILTER
在 4.3 版更改: 现在将此设置为空值可禁用许可证警报。
筛选要显示的许可证列表。将此设置为空可禁用许可证警报。
注解
这个过滤器使用简短的许可证名称。
例如:
LICENSE_FILTER = {"AGPL-3.0", "GPL-3.0-or-later"}
以下为禁用许可证警报的方法:
LICENSE_FILTER = set()
参见
LICENSE_REQUIRED
定义了是否需要 组件配置 中的许可属性。
注解
默认这是关闭的。
LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH
给定翻译的长度是否应被限制。限制为源字符串的长度 * 10 个字符。
提示
将其设置为 False
来允许更长的翻译,而不管源字符串的长度。
注解
默认为 True
。
LOCALIZE_CDN_URL 和 LOCALIZE_CDN_PATH
这些设置配置了 JavaScript 本地化 CDN 插件。 LOCALIZE_CDN_URL
定义了可获得本地化 CDN 的根 URL ,而 LOCALIZE_CDN_PATH
定义了 Weblate 应该存储生成文件的路径,生成的文件在 LOCALIZE_CDN_URL
使用。
提示
在 Hosted Weblate 中,这使用 https://weblate-cdn.com/
。
LOGIN_REQUIRED_URLS
你希望需要登录的 URL 列表。(除了 Weblate 内建立的标准规则)。
提示
这允许密码保护整个安装,通过使用:
LOGIN_REQUIRED_URLS = (r"/(.*)$",)
REST_FRAMEWORK["DEFAULT_PERMISSION_CLASSES"] = [
"rest_framework.permissions.IsAuthenticated"
]
提示
同样想要锁住 API 访问,如上面的例子所示。
LOGIN_REQUIRED_URLS_EXCEPTIONS
用于 LOGIN_REQUIRED_URLS
的例外列表。如果未指定,则允许用户访问登录页。
你可能想要包括的一些例外:
LOGIN_REQUIRED_URLS_EXCEPTIONS = (
r"/accounts/(.*)$", # Required for sign in
r"/static/(.*)$", # Required for development mode
r"/widgets/(.*)$", # Allowing public access to widgets
r"/data/(.*)$", # Allowing public access to data exports
r"/hooks/(.*)$", # Allowing public access to notification hooks
r"/api/(.*)$", # Allowing access to API
r"/js/i18n/$", # JavaScript localization
)
MATOMO_SITE_ID
你想要跟踪的 Matomo(以前的 Piwik)中的网站 ID。
注解
这个集成不支持 Matomo Tag Manager 。
参见
MATOMO_URL
你想用于跟踪 Weblate 使用情况的 Matomo(以前的 Piwik)安装的完整 URL(包括反斜杠)。请查阅 <https://matomo.org/> 了解详情。
提示
这个集成不支持 Matomo Tag Manager 。
例如:
MATOMO_SITE_ID = 1
MATOMO_URL = "https://example.matomo.cloud/"
MT_SERVICES
在 3.0 版更改: 设置从 MACHINE_TRANSLATION_SERVICES
重命名为 MT_SERVICES
,而与其它机器翻译设置一致。
允许使用的机器翻译服务的列表。
注解
很多服务需要像 API 密钥这样的额外配置,请查阅他们的文档 机器翻译 了解详情。
提示
使用 Docker 容器时,此配置根据提供的 API 密钥自动生成,见 机器翻译设置。
MT_SERVICES = (
"weblate.machinery.apertium.ApertiumAPYTranslation",
"weblate.machinery.deepl.DeepLTranslation",
"weblate.machinery.glosbe.GlosbeTranslation",
"weblate.machinery.google.GoogleTranslation",
"weblate.machinery.libretranslate.LibreTranslateTranslation",
"weblate.machinery.microsoft.MicrosoftCognitiveTranslation",
"weblate.machinery.microsoftterminology.MicrosoftTerminologyService",
"weblate.machinery.mymemory.MyMemoryTranslation",
"weblate.machinery.tmserver.AmagamaTranslation",
"weblate.machinery.tmserver.TMServerTranslation",
"weblate.machinery.yandex.YandexTranslation",
"weblate.machinery.weblatetm.WeblateTranslation",
"weblate.machinery.saptranslationhub.SAPTranslationHub",
"weblate.memory.machine.WeblateMemory",
)
MT_APERTIUM_APY
Apertium-APy 服务器的 URL, https://wiki.apertium.org/wiki/Apertium-apy
MT_AWS_ACCESS_KEY_ID
Amazon Translate 的访问密钥 ID 。
MT_AWS_SECRET_ACCESS_KEY
Amazon Translate 的 API 密钥。
MT_AWS_REGION
Amazon Translate 使用的区域名称。
MT_BAIDU_ID
百度智云 API 的客户端 ID ,可以在 https://api.fanyi.baidu.com/api/trans/product/index 注册
参见
MT_BAIDU_SECRET
百度智云 API 的客户端密钥,可以在 https://api.fanyi.baidu.com/api/trans/product/index 注册
参见
MT_DEEPL_API_URL
在 4.7 版更改: The full API URL is now configured to allow using the free plan. Before, it was only possible to
configure the API version using MT_DEEPL_API_VERSION
.
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 默认)用于付费计划的 API 用量,订阅是基于用量的。
https://api-free.deepl.com/v2/
用于免费计划的 API 用量,订阅是基于用量的。
https://api.deepl.com/v1/
用于计算机辅助翻译工具,可以按用户订阅。
之前 Weblate 被 DeepL 归类为计算机辅助翻译(CAT)工具,所以应该使用 v1 API,但现在应该使用 v2 API。因此它默认为 v2,如果您现在有一个计算机辅助翻译工具(CAT )订阅,并希望 Weblate 使用它,您可以将其更改为 v1。
最简单的方法就是在浏览器中打开如下网址:
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.
MT_DEEPL_KEY
DeepL API 的 API 密钥,可以在 https://www.deepl.com/pro.html 注册使用
MT_LIBRETRANSLATE_API_URL
4.7.1 新版功能.
要用的 LibreTranslate 实例的 API URL。
https://libretranslate.com/
(official public instance)Requires an API key to use outside of the website.
Mirrors are documented on the LibreTranslate GitHub repository, some of which can be used without authentication:
https://github.com/LibreTranslate/LibreTranslate#user-content-mirrors
参见
MT_LIBRETRANSLATE_KEY
4.7.1 新版功能.
API key for the LibreTranslate instance specified in MT_LIBRETRANSLATE_API_URL.
参见
MT_GOOGLE_KEY
谷歌翻译 API v2 的 API 密钥,可以在 https://cloud.google.com/translate/docs 上注册使用
MT_GOOGLE_CREDENTIALS
在 Google 云端控制台中获取的 API v3 JSON 凭证文件。请提供完整的操作系统路径。凭证是每个附属于某个项目的服务账户。请查阅 https://cloud.google.com/docs/authentication/getting-started 了解详情。
MT_GOOGLE_PROJECT
已激活翻译服务和账单计费的 Google Cloud API v3 项目 ID。请查阅 https://cloud.google.com/appengine/docs/standard/nodejs/building-app/creating-project 了解详情
MT_GOOGLE_LOCATION
API v3 Google 云应用引擎可能特定于某个位置。如果默认的``global`` 回退无法正常工作,则需要相应地进行更改。
MT_MICROSOFT_BASE_URL
在 “Base URLs” 部分 定义的基于 URL 域名的区域。
Azure Global 的默认值为 api.cognitive.microsofttranslator.com
。
对于 Azure China ,请使用 api.translator.azure.cn
。
MT_MICROSOFT_COGNITIVE_KEY
Microsoft Cognitive Services Translator API 客户端密匙。
MT_MICROSOFT_REGION
“通过一个多服务资源进行验证” 部分中定义的地区前缀。
MT_MICROSOFT_ENDPOINT_URL
在 “Authenticating with an access token” 部分 定义的用于访问令牌的区域端点 URL 域名。
Azure Global 的默认值为 api.cognitive.microsoft.com
。
对于 Azure 中国,请使用你的 Azure Portal 的端点。
MT_MODERNMT_KEY
ModernMT 机器翻译引擎的 API 密钥。
MT_MODERNMT_URL
ModernMT URL 默认值为 https://api.modernmt.com/
。
MT_MYMEMORY_EMAIL
MyMemory 身份电子邮件地址。每天允许 1000 个请求。
MT_MYMEMORY_KEY
MyMemory 访问密钥,用于私有翻译记忆库,与 MT_MYMEMORY_USER
一起使用。
MT_MYMEMORY_USER
MyMemory 用户 ID ,用于私有翻译记忆库,与 :setting:`MT_MYMEMORY_KEY`一起使用。
MT_NETEASE_KEY
NetEase Sight API 的 App 密匙 ,可以在 https://sight.youdao.com/ 注册
参见
MT_NETEASE_SECRET
NetEase Sight API 的 App secret,可以在 https://sight.youdao.com/ 上注册
参见
MT_TMSERVER
正在运行 TMServer 的 URL 。
MT_YANDEX_KEY
Yandex 翻译 API 的 API 密钥,可以在 https://yandex.com/dev/translate/进行 注册
MT_YOUDAO_ID
有道志云 API ID,可以注册在 https://ai.youdao.com/product-fanyi-text.s 。
参见
MT_YOUDAO_SECRET
有道智云 API 密匙,可以在 https://ai.youdao.com/product-fanyi-text.s 注册。
参见
MT_SAP_BASE_URL
SAP Translation Hub 服务的 API URL 。
MT_SAP_SANDBOX_APIKEY
sandbox API 使用的 API 密钥
MT_SAP_USERNAME
SAP 的用户名
MT_SAP_PASSWORD
你的 SAP 密码
MT_SAP_USE_MT
除了术语数据库,是否还使用机器翻译服务。 可能值:True
或 False
NEARBY_MESSAGES
在查看当前翻译字符串时显示多少字符串。这只是默认值,用户可以在 :ref:`user-profile`中调整。
DEFAULT_PAGE_LIMIT
4.7 新版功能.
Default number of elements to display when pagination is active.
PAGURE_CREDENTIALS
4.3.2 新版功能.
Pagure服务器凭据列表。
提示
如果您希望Weblate与更多端点互动,请使用此功能,对于单个Pagure端点,保持设置项 :setting:`PAGURE_USERNAME`和 :setting:`PAGURE_TOKEN`不变即可。
PAGURE_CREDENTIALS = {
"pagure.io": {
"username": "weblate",
"token": "your-api-token",
},
"pagure.example.com": {
"username": "weblate",
"token": "another-api-token",
},
}
PAGURE_USERNAME
4.3.2 新版功能.
Pagure用户名,用于发送翻译更新的合并请求。
PAGURE_TOKEN
4.3.2 新版功能.
Pagure个人访问令牌,用于进行翻译更新的API调用。
PRIVACY_URL
4.8.1 新版功能.
你的 Weblate 实例显示隐私政策的 URL。
提示
在将你的法律文件保存在 Weblate 之外,而将其嵌入 Weblate 的情况下有用。细节请查看 法律声明 。
示例:
PRIVACY_URL = "https://weblate.org/terms/"
参见
RATELIMIT_ATTEMPTS
3.2 新版功能.
在应用次数限制前,身份认证尝试的最多次数。
默认为 5 。
RATELIMIT_WINDOW
3.2 新版功能.
应用次数限制后,可接受多少次身份认证。
秒数默认为 300 ( 5 分钟)。
RATELIMIT_LOCKOUT
3.2 新版功能.
在应用次数限制后,身份认证锁定多久。
秒数默认为 600 ( 10 分钟)。
REGISTRATION_ALLOW_BACKENDS
4.1 新版功能.
身份验证后端的列表,允许从中注册。这只限制新的注册,用户可以使用配置的身份验证后端,来进行身份验证和添加身份验证。
当限制注册后端时,推荐保持 REGISTRATION_OPEN
为开启状态,否则用户将能够注册,但Weblate不会在用户界面显示注册的链接。
示例:
REGISTRATION_ALLOW_BACKENDS = ["azuread-oauth2", "azuread-tenant-oauth2"]
提示
与身份验证 URL 中使用的名称匹配的后端名称。
REGISTRATION_CAPTCHA
True
或 False
的值指示新账户注册是否被 CAPTCHA 保护。这个设置是可选的,默认的 True
是假定不提供。
如果打开,CAPTCHA 会添加到用户输入其电子邮箱地址的所有页面中:
新账户注册。
找回密码。
将电子邮箱地址添加到账户中。
供未登录用户使用的联系表单。
REGISTRATION_EMAIL_MATCH
2.17 新版功能.
允许你筛选哪个电子邮箱地址可以注册。
默认为 .*
,允许使用任何电子邮箱地址注册。
可以用它限制注册到单一的电子邮箱域名:
REGISTRATION_EMAIL_MATCH = r"^.*@weblate\.org$"
REGISTRATION_OPEN
是否注册新账户在当前是允许的。这个可选设置可以保持默认为 True
,或更改为 False
。
这个设置影响了内建的通过电子邮箱地址或通过 Python Social Auth 的身份验证( 可以使用 REGISTRATION_ALLOW_BACKENDS
为适当的后端建立白名单)。
注解
如果使用第三方身份验证方法,如 LDAP 身份验证 ,只是隐藏注册表单,而新用户仍然能够登录并建立账户。
REPOSITORY_ALERT_THRESHOLD
4.0.2 新版功能.
触发仓库过期警报的阈值,或者包含了太多更改的阈值。默认为 25 。
参见
REQUIRE_LOGIN
4.1 新版功能.
这会启用 LOGIN_REQUIRED_URLS
并配置 REST 框架来对所有 API 端点都要求登录。
注解
这实现在 sample-configuration`中。对于 Docker,使用 :envvar:`WEBLATE_REQUIRE_LOGIN。
SENTRY_DSN
3.9 新版功能.
Sentry DSN 用于 收集错误报告 。
SIMPLIFY_LANGUAGES
对于默认语言/国家组合使用简单语言代码。例如, fr_FR
翻译将使用 fr
语言代码。这通常是受欢迎的特性,因为它简化了这些默认组合列出的语言。
如果对每种不同的变化想要不同的翻译,那么请将其关闭。
SITE_DOMAIN
配置网站域名。这对于在很多地方获得正确的绝对链接是必要的(例如激活邮箱、通知或 RSS 订阅源)。
在 Weblate 运行在非标准端口时,这里同样要包括它。
例子:
# Production site with domain name
SITE_DOMAIN = "weblate.example.com"
# Local development with IP address and port
SITE_DOMAIN = "127.0.0.1:8000"
注解
这个设置应该只包含域名。对于配置协议,(允许或强制 HTTPS )使用 ENABLE_HTTPS
and for changing URL, use URL_PREFIX
。
提示
关于 Docker 容器,网站域名通过 WEBLATE_ALLOWED_HOSTS
来配置。
SITE_TITLE
用于网站和发送电子邮件的网站名称。
SPECIAL_CHARS
屏幕键盘中包括的另外的字符, 虚拟键盘 。
默认值为:
SPECIAL_CHARS = ("\t", "\n", "\u00a0", "…")
SINGLE_PROJECT
3.8 新版功能.
将用户直接重定向到项目或组件,而不是显示控制面板。可以将其设置为 True
,在这种情况下,只在 Weblate 实际只有单一的项目时有用。另外可以设置项目标识串,将无条件地重定向到这个项目。
在 3.11 版更改: 设置只接受项目标识串,来强制显示那个单一项目。
示例:
SINGLE_PROJECT = "test"
SSH_EXTRA_ARGS
4.9 新版功能.
Allows to add custom parameters when Weblate is invoking SSH. This is useful when connecting to servers using legacy encryption or other non-standard features.
For example when SSH connection in Weblate fails with Unable to negotiate with legacyhost: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1, you can enable that using:
SSH_EXTRA_ARGS = "-oKexAlgorithms=+diffie-hellman-group1-sha1"
提示
The string is evaluated by shell, so make sure to quote any whitespace and special characters.
参见
STATUS_URL
你的 Weblate 实例报告其状态的 URL。
SUGGESTION_CLEANUP_DAYS
3.2.1 新版功能.
给定天数后自动删除建议。默认为 None
,意味着不删除。
UPDATE_LANGUAGES
4.3.2 新版功能.
控制在运行数据库迁移时是否应该更新语言数据库并在默认情况下启用。这个设置对 :djadmin: setuplang 的调用没有影响。
参见
URL_PREFIX
这个设置允许在一些路径下运行 Weblate (否则它依赖于从 web 服务器根目录运行)。
注解
为了使用这个设置,还需要配置服务器来去掉这个前缀。例如 WSGI ,可以通过设置 WSGIScriptAlias
来实现。
提示
前缀应该以 /
开始。
示例:
URL_PREFIX = "/translations"
注解
这个设置在 Django’s 内建服务器中不起作用,必须调整 urls.py
来包含这个前缀。
VCS_BACKENDS
可用的版本控制系统(VCS)后端的配置。
注解
Weblate 尝试使用你所有工具支持的后端。
提示
可以使用这个来限制选择或添加定制版本控制系统(VCS)后端。
VCS_BACKENDS = ("weblate.vcs.git.GitRepository",)
参见
VCS_CLONE_DEPTH
3.10.2 新版功能.
配置 Weblate应该对仓库进行深度为多少的克隆。
注解
当前这只在 Git 中支持。默认 Weblate 进行仓库的浅克隆,使克隆更快并节省磁盘空间。根据应用(例如当使用定制的 附加组件 时),你可能想要增加深度,或通过设置为 0 来完全关闭浅克隆。
提示
在从 Weblate 推送而得到 fatal: protocol error: expected old/new/ref, got 'shallow <commit hash>'
错误的情况下,通过设置来完全关闭浅克隆:
VCS_CLONE_DEPTH = 0
WEBLATE_ADDONS
附加组件可供使用的附加组件列表。为了使用,必须对给定的翻译组件允许它们。默认包括了所有内建附加组件,当扩展列表时您可能希望保持现有的附加组件处于启用状态,例如:
WEBLATE_ADDONS = (
# Built-in addons
"weblate.addons.gettext.GenerateMoAddon",
"weblate.addons.gettext.UpdateLinguasAddon",
"weblate.addons.gettext.UpdateConfigureAddon",
"weblate.addons.gettext.MsgmergeAddon",
"weblate.addons.gettext.GettextCustomizeAddon",
"weblate.addons.gettext.GettextAuthorComments",
"weblate.addons.cleanup.CleanupAddon",
"weblate.addons.consistency.LangaugeConsistencyAddon",
"weblate.addons.discovery.DiscoveryAddon",
"weblate.addons.flags.SourceEditAddon",
"weblate.addons.flags.TargetEditAddon",
"weblate.addons.flags.SameEditAddon",
"weblate.addons.flags.BulkEditAddon",
"weblate.addons.generate.GenerateFileAddon",
"weblate.addons.json.JSONCustomizeAddon",
"weblate.addons.properties.PropertiesSortAddon",
"weblate.addons.git.GitSquashAddon",
"weblate.addons.removal.RemoveComments",
"weblate.addons.removal.RemoveSuggestions",
"weblate.addons.resx.ResxUpdateAddon",
"weblate.addons.autotranslate.AutoTranslateAddon",
"weblate.addons.yaml.YAMLCustomizeAddon",
"weblate.addons.cdn.CDNJSAddon",
# Add-on you want to include
"weblate.addons.example.ExampleAddon",
)
注解
从列表中删除插件并不将它从组件中卸载。Weblate 在这种情况下会崩溃。请在从这个列表中删除前从所有组件中卸载插件。
参见
WEBLATE_EXPORTERS
4.2 新版功能.
可用的导出程序列表,提供下载各种文件格式的翻译或术语表。
参见
WEBLATE_FORMATS
3.0 新版功能.
可供使用的文件格式列表。
注解
默认列表已经具有了常见格式。
参见
WEBLATE_GPG_IDENTITY
3.1 新版功能.
Weblate 对 Git 提交进行签名的身份,例如:
WEBLATE_GPG_IDENTITY = "Weblate <weblate@example.com>"
在 Weblate GPG 密钥环中搜索匹配的密钥(DATA_DIR
下的 home/.gnupg
)。如果找不到,则会生成一个密钥,请查阅 使用 GnuPG 为 Git 提交签名 了解详情。
WEBSITE_REQUIRED
Defines whether 项目网站 has to be specified when creating a project. Turned on by default as that suits public server setups.
配置的例子
后面的例子作为 weblate/settings_example.py
与Weblate一起上市:
#
# 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/>.
#
import os
import platform
from logging.handlers import SysLogHandler
# Title of site to use
SITE_TITLE = "Weblate"
# Site domain
SITE_DOMAIN = ""
# Whether site uses https
ENABLE_HTTPS = False
#
# Django settings for Weblate project.
#
DEBUG = True
ADMINS = (
# ("Your Name", "your_email@example.com"),
)
MANAGERS = ADMINS
DATABASES = {
"default": {
# Use "postgresql" or "mysql".
"ENGINE": "django.db.backends.postgresql",
# Database name.
"NAME": "weblate",
# Database user.
"USER": "weblate",
# Name of role to alter to set parameters in PostgreSQL,
# use in case role name is different than user used for authentication.
# "ALTER_ROLE": "weblate",
# Database password.
"PASSWORD": "",
# Set to empty string for localhost.
"HOST": "127.0.0.1",
# Set to empty string for default.
"PORT": "",
# Customizations for databases.
"OPTIONS": {
# In case of using an older MySQL server,
# which has MyISAM as a default storage
# "init_command": "SET storage_engine=INNODB",
# Uncomment for MySQL older than 5.7:
# "init_command": "SET sql_mode='STRICT_TRANS_TABLES'",
# Set emoji capable charset for MySQL:
# "charset": "utf8mb4",
# Change connection timeout in case you get MySQL gone away error:
# "connect_timeout": 28800,
},
# Persistent connections
"CONN_MAX_AGE": 0,
# Disable server-side cursors, might be needed with pgbouncer
"DISABLE_SERVER_SIDE_CURSORS": False,
}
}
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Data directory
DATA_DIR = os.path.join(BASE_DIR, "data")
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = "UTC"
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = "en-us"
LANGUAGES = (
("ar", "العربية"),
("az", "Azərbaycan"),
("be", "Беларуская"),
("be@latin", "Biełaruskaja"),
("bg", "Български"),
("br", "Brezhoneg"),
("ca", "Català"),
("cs", "Čeština"),
("da", "Dansk"),
("de", "Deutsch"),
("en", "English"),
("el", "Ελληνικά"),
("en-gb", "English (United Kingdom)"),
("es", "Español"),
("fi", "Suomi"),
("fr", "Français"),
("gl", "Galego"),
("he", "עברית"),
("hu", "Magyar"),
("hr", "Hrvatski"),
("id", "Indonesia"),
("is", "Íslenska"),
("it", "Italiano"),
("ja", "日本語"),
("kab", "Taqbaylit"),
("kk", "Қазақ тілі"),
("ko", "한국어"),
("nb", "Norsk bokmål"),
("nl", "Nederlands"),
("pl", "Polski"),
("pt", "Português"),
("pt-br", "Português brasileiro"),
("ro", "Română"),
("ru", "Русский"),
("sk", "Slovenčina"),
("sl", "Slovenščina"),
("sq", "Shqip"),
("sr", "Српски"),
("sr-latn", "Srpski"),
("sv", "Svenska"),
("th", "ไทย"),
("tr", "Türkçe"),
("uk", "Українська"),
("zh-hans", "简体字"),
("zh-hant", "正體字"),
)
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Type of automatic primary key, introduced in Django 3.2
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
# URL prefix to use, please see documentation for more details
URL_PREFIX = ""
# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = os.path.join(DATA_DIR, "media")
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
MEDIA_URL = f"{URL_PREFIX}/media/"
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
STATIC_ROOT = os.path.join(DATA_DIR, "static")
# URL prefix for static files.
STATIC_URL = f"{URL_PREFIX}/static/"
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
"compressor.finders.CompressorFinder",
)
# Make this unique, and don't share it with anybody.
# You can generate it using weblate/examples/generate-secret-key
SECRET_KEY = ""
_TEMPLATE_LOADERS = [
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
]
if not DEBUG:
_TEMPLATE_LOADERS = [("django.template.loaders.cached.Loader", _TEMPLATE_LOADERS)]
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"OPTIONS": {
"context_processors": [
"django.contrib.auth.context_processors.auth",
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.request",
"django.template.context_processors.csrf",
"django.contrib.messages.context_processors.messages",
"weblate.trans.context_processors.weblate_context",
],
"loaders": _TEMPLATE_LOADERS,
},
}
]
# GitHub username and token for sending pull requests.
# Please see the documentation for more details.
GITHUB_USERNAME = None
GITHUB_TOKEN = None
# GitLab username and token for sending merge requests.
# Please see the documentation for more details.
GITLAB_USERNAME = None
GITLAB_TOKEN = None
# Authentication configuration
AUTHENTICATION_BACKENDS = (
"social_core.backends.email.EmailAuth",
# "social_core.backends.google.GoogleOAuth2",
# "social_core.backends.github.GithubOAuth2",
# "social_core.backends.bitbucket.BitbucketOAuth",
# "social_core.backends.suse.OpenSUSEOpenId",
# "social_core.backends.ubuntu.UbuntuOpenId",
# "social_core.backends.fedora.FedoraOpenId",
# "social_core.backends.facebook.FacebookOAuth2",
"weblate.accounts.auth.WeblateUserBackend",
)
# Custom user model
AUTH_USER_MODEL = "weblate_auth.User"
# Social auth backends setup
SOCIAL_AUTH_GITHUB_KEY = ""
SOCIAL_AUTH_GITHUB_SECRET = ""
SOCIAL_AUTH_GITHUB_SCOPE = ["user:email"]
SOCIAL_AUTH_GITHUB_ORG_KEY = ""
SOCIAL_AUTH_GITHUB_ORG_SECRET = ""
SOCIAL_AUTH_GITHUB_ORG_NAME = ""
SOCIAL_AUTH_GITHUB_TEAM_KEY = ""
SOCIAL_AUTH_GITHUB_TEAM_SECRET = ""
SOCIAL_AUTH_GITHUB_TEAM_ID = ""
SOCIAL_AUTH_BITBUCKET_KEY = ""
SOCIAL_AUTH_BITBUCKET_SECRET = ""
SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True
SOCIAL_AUTH_FACEBOOK_KEY = ""
SOCIAL_AUTH_FACEBOOK_SECRET = ""
SOCIAL_AUTH_FACEBOOK_SCOPE = ["email", "public_profile"]
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {"fields": "id,name,email"}
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ""
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ""
# Social auth settings
SOCIAL_AUTH_PIPELINE = (
"social_core.pipeline.social_auth.social_details",
"social_core.pipeline.social_auth.social_uid",
"social_core.pipeline.social_auth.auth_allowed",
"social_core.pipeline.social_auth.social_user",
"weblate.accounts.pipeline.store_params",
"weblate.accounts.pipeline.verify_open",
"social_core.pipeline.user.get_username",
"weblate.accounts.pipeline.require_email",
"social_core.pipeline.mail.mail_validation",
"weblate.accounts.pipeline.revoke_mail_code",
"weblate.accounts.pipeline.ensure_valid",
"weblate.accounts.pipeline.remove_account",
"social_core.pipeline.social_auth.associate_by_email",
"weblate.accounts.pipeline.reauthenticate",
"weblate.accounts.pipeline.verify_username",
"social_core.pipeline.user.create_user",
"social_core.pipeline.social_auth.associate_user",
"social_core.pipeline.social_auth.load_extra_data",
"weblate.accounts.pipeline.cleanup_next",
"weblate.accounts.pipeline.user_full_name",
"weblate.accounts.pipeline.store_email",
"weblate.accounts.pipeline.notify_connect",
"weblate.accounts.pipeline.password_reset",
)
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
"social_core.pipeline.disconnect.allowed_to_disconnect",
"social_core.pipeline.disconnect.get_entries",
"social_core.pipeline.disconnect.revoke_tokens",
"weblate.accounts.pipeline.cycle_session",
"weblate.accounts.pipeline.adjust_primary_mail",
"weblate.accounts.pipeline.notify_disconnect",
"social_core.pipeline.disconnect.disconnect",
"weblate.accounts.pipeline.cleanup_next",
)
# Custom authentication strategy
SOCIAL_AUTH_STRATEGY = "weblate.accounts.strategy.WeblateStrategy"
# Raise exceptions so that we can handle them later
SOCIAL_AUTH_RAISE_EXCEPTIONS = True
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION = "weblate.accounts.pipeline.send_validation"
SOCIAL_AUTH_EMAIL_VALIDATION_URL = f"{URL_PREFIX}/accounts/email-sent/"
SOCIAL_AUTH_LOGIN_ERROR_URL = f"{URL_PREFIX}/accounts/login/"
SOCIAL_AUTH_EMAIL_FORM_URL = f"{URL_PREFIX}/accounts/email/"
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = f"{URL_PREFIX}/accounts/profile/#account"
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ("email",)
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
SOCIAL_AUTH_SLUGIFY_FUNCTION = "weblate.accounts.pipeline.slugify_username"
# Password validation configuration
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" # noqa: E501, pylint: disable=line-too-long
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
"OPTIONS": {"min_length": 10},
},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
{"NAME": "weblate.accounts.password_validation.CharsPasswordValidator"},
{"NAME": "weblate.accounts.password_validation.PastPasswordsValidator"},
# Optional password strength validation by django-zxcvbn-password
# {
# "NAME": "zxcvbn_password.ZXCVBNValidator",
# "OPTIONS": {
# "min_score": 3,
# "user_attributes": ("username", "email", "full_name")
# }
# },
]
# Password hashing (prefer Argon)
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.Argon2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
]
# Allow new user registrations
REGISTRATION_OPEN = True
# Shortcut for login required setting
REQUIRE_LOGIN = False
# Middleware
MIDDLEWARE = [
"weblate.middleware.RedirectMiddleware",
"weblate.middleware.ProxyMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"weblate.accounts.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"social_django.middleware.SocialAuthExceptionMiddleware",
"weblate.accounts.middleware.RequireLoginMiddleware",
"weblate.api.middleware.ThrottlingMiddleware",
"weblate.middleware.SecurityMiddleware",
"weblate.wladmin.middleware.ManageMiddleware",
]
ROOT_URLCONF = "weblate.urls"
# Django and Weblate apps
INSTALLED_APPS = [
# Weblate apps on top to override Django locales and templates
"weblate.addons",
"weblate.auth",
"weblate.checks",
"weblate.formats",
"weblate.glossary",
"weblate.machinery",
"weblate.trans",
"weblate.lang",
"weblate_language_data",
"weblate.memory",
"weblate.screenshots",
"weblate.fonts",
"weblate.accounts",
"weblate.configuration",
"weblate.utils",
"weblate.vcs",
"weblate.wladmin",
"weblate.metrics",
"weblate",
# Optional: Git exporter
"weblate.gitexport",
# Standard Django modules
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.admin.apps.SimpleAdminConfig",
"django.contrib.admindocs",
"django.contrib.sitemaps",
"django.contrib.humanize",
# Third party Django modules
"social_django",
"crispy_forms",
"compressor",
"rest_framework",
"rest_framework.authtoken",
"django_filters",
]
# Custom exception reporter to include some details
DEFAULT_EXCEPTION_REPORTER_FILTER = "weblate.trans.debug.WeblateExceptionReporterFilter"
# Default logging of Weblate messages
# - to syslog in production (if available)
# - otherwise to console
# - you can also choose "logfile" to log into separate file
# after configuring it below
# Detect if we can connect to syslog
HAVE_SYSLOG = False
if platform.system() != "Windows":
try:
handler = SysLogHandler(address="/dev/log", facility=SysLogHandler.LOG_LOCAL2)
handler.close()
HAVE_SYSLOG = True
except OSError:
HAVE_SYSLOG = False
if DEBUG or not HAVE_SYSLOG:
DEFAULT_LOG = "console"
else:
DEFAULT_LOG = "syslog"
DEFAULT_LOGLEVEL = "DEBUG" if DEBUG else "INFO"
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/stable/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
"formatters": {
"syslog": {"format": "weblate[%(process)d]: %(levelname)s %(message)s"},
"simple": {"format": "[%(asctime)s: %(levelname)s/%(process)s] %(message)s"},
"logfile": {"format": "%(asctime)s %(levelname)s %(message)s"},
"django.server": {
"()": "django.utils.log.ServerFormatter",
"format": "[%(server_time)s] %(message)s",
},
},
"handlers": {
"mail_admins": {
"level": "ERROR",
"filters": ["require_debug_false"],
"class": "django.utils.log.AdminEmailHandler",
"include_html": True,
},
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "simple",
},
"django.server": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "django.server",
},
"syslog": {
"level": "DEBUG",
"class": "logging.handlers.SysLogHandler",
"formatter": "syslog",
"address": "/dev/log",
"facility": SysLogHandler.LOG_LOCAL2,
},
# Logging to a file
# "logfile": {
# "level":"DEBUG",
# "class":"logging.handlers.RotatingFileHandler",
# "filename": "/var/log/weblate/weblate.log",
# "maxBytes": 100000,
# "backupCount": 3,
# "formatter": "logfile",
# },
},
"loggers": {
"django.request": {
"handlers": ["mail_admins", DEFAULT_LOG],
"level": "ERROR",
"propagate": True,
},
"django.server": {
"handlers": ["django.server"],
"level": "INFO",
"propagate": False,
},
# Logging database queries
# "django.db.backends": {
# "handlers": [DEFAULT_LOG],
# "level": "DEBUG",
# },
"weblate": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL},
# Logging VCS operations
"weblate.vcs": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL},
# Python Social Auth
"social": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL},
# Django Authentication Using LDAP
"django_auth_ldap": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL},
# SAML IdP
"djangosaml2idp": {"handlers": [DEFAULT_LOG], "level": DEFAULT_LOGLEVEL},
},
}
# Remove syslog setup if it's not present
if not HAVE_SYSLOG:
del LOGGING["handlers"]["syslog"]
# List of machine translations
MT_SERVICES = (
# "weblate.machinery.apertium.ApertiumAPYTranslation",
# "weblate.machinery.baidu.BaiduTranslation",
# "weblate.machinery.deepl.DeepLTranslation",
# "weblate.machinery.glosbe.GlosbeTranslation",
# "weblate.machinery.google.GoogleTranslation",
# "weblate.machinery.googlev3.GoogleV3Translation",
# "weblate.machinery.libretranslate.LibreTranslateTranslation",
# "weblate.machinery.microsoft.MicrosoftCognitiveTranslation",
# "weblate.machinery.microsoftterminology.MicrosoftTerminologyService",
# "weblate.machinery.modernmt.ModernMTTranslation",
# "weblate.machinery.mymemory.MyMemoryTranslation",
# "weblate.machinery.netease.NeteaseSightTranslation",
# "weblate.machinery.tmserver.AmagamaTranslation",
# "weblate.machinery.tmserver.TMServerTranslation",
# "weblate.machinery.yandex.YandexTranslation",
# "weblate.machinery.saptranslationhub.SAPTranslationHub",
# "weblate.machinery.youdao.YoudaoTranslation",
"weblate.machinery.weblatetm.WeblateTranslation",
"weblate.memory.machine.WeblateMemory",
)
# Machine translation API keys
# URL of the Apertium APy server
MT_APERTIUM_APY = None
# DeepL API key
MT_DEEPL_KEY = None
# LibreTranslate
MT_LIBRETRANSLATE_API_URL = None
MT_LIBRETRANSLATE_KEY = None
# Microsoft Cognitive Services Translator API, register at
# https://portal.azure.com/
MT_MICROSOFT_COGNITIVE_KEY = None
MT_MICROSOFT_REGION = None
# ModernMT
MT_MODERNMT_KEY = None
# MyMemory identification email, see
# https://mymemory.translated.net/doc/spec.php
MT_MYMEMORY_EMAIL = None
# Optional MyMemory credentials to access private translation memory
MT_MYMEMORY_USER = None
MT_MYMEMORY_KEY = None
# Google API key for Google Translate API v2
MT_GOOGLE_KEY = None
# Google Translate API3 credentials and project id
MT_GOOGLE_CREDENTIALS = None
MT_GOOGLE_PROJECT = None
# Baidu app key and secret
MT_BAIDU_ID = None
MT_BAIDU_SECRET = None
# Youdao Zhiyun app key and secret
MT_YOUDAO_ID = None
MT_YOUDAO_SECRET = None
# Netease Sight (Jianwai) app key and secret
MT_NETEASE_KEY = None
MT_NETEASE_SECRET = None
# API key for Yandex Translate API
MT_YANDEX_KEY = None
# tmserver URL
MT_TMSERVER = None
# SAP Translation Hub
MT_SAP_BASE_URL = None
MT_SAP_SANDBOX_APIKEY = None
MT_SAP_USERNAME = None
MT_SAP_PASSWORD = None
MT_SAP_USE_MT = True
# Use HTTPS when creating redirect URLs for social authentication, see
# documentation for more details:
# https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen
SOCIAL_AUTH_REDIRECT_IS_HTTPS = ENABLE_HTTPS
# Make CSRF cookie HttpOnly, see documentation for more details:
# https://docs.djangoproject.com/en/1.11/ref/settings/#csrf-cookie-httponly
CSRF_COOKIE_HTTPONLY = True
CSRF_COOKIE_SECURE = ENABLE_HTTPS
# Store CSRF token in session
CSRF_USE_SESSIONS = True
# Customize CSRF failure view
CSRF_FAILURE_VIEW = "weblate.trans.views.error.csrf_failure"
SESSION_COOKIE_SECURE = ENABLE_HTTPS
SESSION_COOKIE_HTTPONLY = True
# SSL redirect
SECURE_SSL_REDIRECT = ENABLE_HTTPS
# Sent referrrer only for same origin links
SECURE_REFERRER_POLICY = "same-origin"
# SSL redirect URL exemption list
SECURE_REDIRECT_EXEMPT = (r"healthz/$",) # Allowing HTTP access to health check
# Session cookie age (in seconds)
SESSION_COOKIE_AGE = 1000
SESSION_COOKIE_AGE_AUTHENTICATED = 1209600
SESSION_COOKIE_SAMESITE = "Lax"
# Increase allowed upload size
DATA_UPLOAD_MAX_MEMORY_SIZE = 50000000
# Apply session coookie settings to language cookie as ewll
LANGUAGE_COOKIE_SECURE = SESSION_COOKIE_SECURE
LANGUAGE_COOKIE_HTTPONLY = SESSION_COOKIE_HTTPONLY
LANGUAGE_COOKIE_AGE = SESSION_COOKIE_AGE_AUTHENTICATED * 10
LANGUAGE_COOKIE_SAMESITE = SESSION_COOKIE_SAMESITE
# Some security headers
SECURE_BROWSER_XSS_FILTER = True
X_FRAME_OPTIONS = "DENY"
SECURE_CONTENT_TYPE_NOSNIFF = True
# Optionally enable HSTS
SECURE_HSTS_SECONDS = 31536000 if ENABLE_HTTPS else 0
SECURE_HSTS_PRELOAD = ENABLE_HTTPS
SECURE_HSTS_INCLUDE_SUBDOMAINS = ENABLE_HTTPS
# HTTPS detection behind reverse proxy
SECURE_PROXY_SSL_HEADER = None
# URL of login
LOGIN_URL = f"{URL_PREFIX}/accounts/login/"
# URL of logout
LOGOUT_URL = f"{URL_PREFIX}/accounts/logout/"
# Default location for login
LOGIN_REDIRECT_URL = f"{URL_PREFIX}/"
# Anonymous user name
ANONYMOUS_USER_NAME = "anonymous"
# Reverse proxy settings
IP_PROXY_HEADER = "HTTP_X_FORWARDED_FOR"
IP_BEHIND_REVERSE_PROXY = False
IP_PROXY_OFFSET = 0
# Sending HTML in mails
EMAIL_SEND_HTML = True
# Subject of emails includes site title
EMAIL_SUBJECT_PREFIX = f"[{SITE_TITLE}] "
# Enable remote hooks
ENABLE_HOOKS = True
# By default the length of a given translation is limited to the length of
# the source string * 10 characters. Set this option to False to allow longer
# translations (up to 10.000 characters)
LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH = True
# Use simple language codes for default language/country combinations
SIMPLIFY_LANGUAGES = True
# Render forms using bootstrap
CRISPY_TEMPLATE_PACK = "bootstrap3"
# List of quality checks
# CHECK_LIST = (
# "weblate.checks.same.SameCheck",
# "weblate.checks.chars.BeginNewlineCheck",
# "weblate.checks.chars.EndNewlineCheck",
# "weblate.checks.chars.BeginSpaceCheck",
# "weblate.checks.chars.EndSpaceCheck",
# "weblate.checks.chars.DoubleSpaceCheck",
# "weblate.checks.chars.EndStopCheck",
# "weblate.checks.chars.EndColonCheck",
# "weblate.checks.chars.EndQuestionCheck",
# "weblate.checks.chars.EndExclamationCheck",
# "weblate.checks.chars.EndEllipsisCheck",
# "weblate.checks.chars.EndSemicolonCheck",
# "weblate.checks.chars.MaxLengthCheck",
# "weblate.checks.chars.KashidaCheck",
# "weblate.checks.chars.PunctuationSpacingCheck",
# "weblate.checks.format.PythonFormatCheck",
# "weblate.checks.format.PythonBraceFormatCheck",
# "weblate.checks.format.PHPFormatCheck",
# "weblate.checks.format.CFormatCheck",
# "weblate.checks.format.PerlFormatCheck",
# "weblate.checks.format.JavaScriptFormatCheck",
# "weblate.checks.format.LuaFormatCheck",
# "weblate.checks.format.ObjectPascalFormatCheck",
# "weblate.checks.format.SchemeFormatCheck",
# "weblate.checks.format.CSharpFormatCheck",
# "weblate.checks.format.JavaFormatCheck",
# "weblate.checks.format.JavaMessageFormatCheck",
# "weblate.checks.format.PercentPlaceholdersCheck",
# "weblate.checks.format.VueFormattingCheck",
# "weblate.checks.format.I18NextInterpolationCheck",
# "weblate.checks.format.ESTemplateLiteralsCheck",
# "weblate.checks.angularjs.AngularJSInterpolationCheck",
# "weblate.checks.icu.ICUMessageFormatCheck",
# "weblate.checks.icu.ICUSourceCheck",
# "weblate.checks.qt.QtFormatCheck",
# "weblate.checks.qt.QtPluralCheck",
# "weblate.checks.ruby.RubyFormatCheck",
# "weblate.checks.consistency.PluralsCheck",
# "weblate.checks.consistency.SamePluralsCheck",
# "weblate.checks.consistency.ConsistencyCheck",
# "weblate.checks.consistency.TranslatedCheck",
# "weblate.checks.chars.EscapedNewlineCountingCheck",
# "weblate.checks.chars.NewLineCountCheck",
# "weblate.checks.markup.BBCodeCheck",
# "weblate.checks.chars.ZeroWidthSpaceCheck",
# "weblate.checks.render.MaxSizeCheck",
# "weblate.checks.markup.XMLValidityCheck",
# "weblate.checks.markup.XMLTagsCheck",
# "weblate.checks.markup.MarkdownRefLinkCheck",
# "weblate.checks.markup.MarkdownLinkCheck",
# "weblate.checks.markup.MarkdownSyntaxCheck",
# "weblate.checks.markup.URLCheck",
# "weblate.checks.markup.SafeHTMLCheck",
# "weblate.checks.placeholders.PlaceholderCheck",
# "weblate.checks.placeholders.RegexCheck",
# "weblate.checks.duplicate.DuplicateCheck",
# "weblate.checks.source.OptionalPluralCheck",
# "weblate.checks.source.EllipsisCheck",
# "weblate.checks.source.MultipleFailingCheck",
# "weblate.checks.source.LongUntranslatedCheck",
# "weblate.checks.format.MultipleUnnamedFormatsCheck",
# "weblate.checks.glossary.GlossaryCheck",
# )
# List of automatic fixups
# AUTOFIX_LIST = (
# "weblate.trans.autofixes.whitespace.SameBookendingWhitespace",
# "weblate.trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis",
# "weblate.trans.autofixes.chars.RemoveZeroSpace",
# "weblate.trans.autofixes.chars.RemoveControlChars",
# )
# List of enabled addons
# WEBLATE_ADDONS = (
# "weblate.addons.gettext.GenerateMoAddon",
# "weblate.addons.gettext.UpdateLinguasAddon",
# "weblate.addons.gettext.UpdateConfigureAddon",
# "weblate.addons.gettext.MsgmergeAddon",
# "weblate.addons.gettext.GettextCustomizeAddon",
# "weblate.addons.gettext.GettextAuthorComments",
# "weblate.addons.cleanup.CleanupAddon",
# "weblate.addons.cleanup.RemoveBlankAddon",
# "weblate.addons.consistency.LangaugeConsistencyAddon",
# "weblate.addons.discovery.DiscoveryAddon",
# "weblate.addons.autotranslate.AutoTranslateAddon",
# "weblate.addons.flags.SourceEditAddon",
# "weblate.addons.flags.TargetEditAddon",
# "weblate.addons.flags.SameEditAddon",
# "weblate.addons.flags.BulkEditAddon",
# "weblate.addons.generate.GenerateFileAddon",
# "weblate.addons.generate.PseudolocaleAddon",
# "weblate.addons.json.JSONCustomizeAddon",
# "weblate.addons.properties.PropertiesSortAddon",
# "weblate.addons.git.GitSquashAddon",
# "weblate.addons.removal.RemoveComments",
# "weblate.addons.removal.RemoveSuggestions",
# "weblate.addons.resx.ResxUpdateAddon",
# "weblate.addons.yaml.YAMLCustomizeAddon",
# "weblate.addons.cdn.CDNJSAddon",
# )
# E-mail address that error messages come from.
SERVER_EMAIL = "noreply@example.com"
# Default email address to use for various automated correspondence from
# the site managers. Used for registration emails.
DEFAULT_FROM_EMAIL = "noreply@example.com"
# List of URLs your site is supposed to serve
ALLOWED_HOSTS = ["*"]
# Configuration for caching
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
# If redis is running on same host as Weblate, you might
# want to use unix sockets instead:
# "LOCATION": "unix:///var/run/redis/redis.sock?db=1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"PARSER_CLASS": "redis.connection.HiredisParser",
# If you set password here, adjust CELERY_BROKER_URL as well
"PASSWORD": None,
"CONNECTION_POOL_KWARGS": {},
},
"KEY_PREFIX": "weblate",
},
"avatar": {
"BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
"LOCATION": os.path.join(DATA_DIR, "avatar-cache"),
"TIMEOUT": 86400,
"OPTIONS": {"MAX_ENTRIES": 1000},
},
}
# Store sessions in cache
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
# Store messages in session
MESSAGE_STORAGE = "django.contrib.messages.storage.session.SessionStorage"
# REST framework settings for API
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
"DEFAULT_PERMISSION_CLASSES": [
# Require authentication for login required sites
"rest_framework.permissions.IsAuthenticated"
if REQUIRE_LOGIN
else "rest_framework.permissions.IsAuthenticatedOrReadOnly"
],
"DEFAULT_AUTHENTICATION_CLASSES": (
"weblate.api.authentication.ProjectTokenAuthentication",
"rest_framework.authentication.TokenAuthentication",
"weblate.api.authentication.BearerAuthentication",
"rest_framework.authentication.SessionAuthentication",
),
"DEFAULT_THROTTLE_CLASSES": (
"weblate.api.throttling.UserRateThrottle",
"weblate.api.throttling.AnonRateThrottle",
),
"DEFAULT_THROTTLE_RATES": {"anon": "100/day", "user": "5000/hour"},
"DEFAULT_PAGINATION_CLASS": ("rest_framework.pagination.PageNumberPagination"),
"PAGE_SIZE": 20,
"VIEW_DESCRIPTION_FUNCTION": "weblate.api.views.get_view_description",
"UNAUTHENTICATED_USER": "weblate.auth.models.get_anonymous",
}
# Fonts CDN URL
FONTS_CDN_URL = None
# Django compressor offline mode
COMPRESS_OFFLINE = False
COMPRESS_OFFLINE_CONTEXT = [
{"fonts_cdn_url": FONTS_CDN_URL, "STATIC_URL": STATIC_URL, "LANGUAGE_BIDI": True},
{"fonts_cdn_url": FONTS_CDN_URL, "STATIC_URL": STATIC_URL, "LANGUAGE_BIDI": False},
]
# Require login for all URLs
if REQUIRE_LOGIN:
LOGIN_REQUIRED_URLS = (r"/(.*)$",)
# In such case you will want to include some of the exceptions
# LOGIN_REQUIRED_URLS_EXCEPTIONS = (
# rf"{URL_PREFIX}/accounts/(.*)$", # Required for login
# rf"{URL_PREFIX}/admin/login/(.*)$", # Required for admin login
# rf"{URL_PREFIX}/static/(.*)$", # Required for development mode
# rf"{URL_PREFIX}/widgets/(.*)$", # Allowing public access to widgets
# rf"{URL_PREFIX}/data/(.*)$", # Allowing public access to data exports
# rf"{URL_PREFIX}/hooks/(.*)$", # Allowing public access to notification hooks
# rf"{URL_PREFIX}/healthz/$", # Allowing public access to health check
# rf"{URL_PREFIX}/api/(.*)$", # Allowing access to API
# rf"{URL_PREFIX}/js/i18n/$", # JavaScript localization
# rf"{URL_PREFIX}/contact/$", # Optional for contact form
# rf"{URL_PREFIX}/legal/(.*)$", # Optional for legal app
# )
# Silence some of the Django system checks
SILENCED_SYSTEM_CHECKS = [
# We have modified django.contrib.auth.middleware.AuthenticationMiddleware
# as weblate.accounts.middleware.AuthenticationMiddleware
"admin.E408"
]
# Celery worker configuration for testing
# CELERY_TASK_ALWAYS_EAGER = True
# CELERY_BROKER_URL = "memory://"
# CELERY_TASK_EAGER_PROPAGATES = True
# Celery worker configuration for production
CELERY_TASK_ALWAYS_EAGER = False
CELERY_BROKER_URL = "redis://localhost:6379"
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
# Celery settings, it is not recommended to change these
CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000
CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(DATA_DIR, "celery", "beat-schedule")
CELERY_TASK_ROUTES = {
"weblate.trans.tasks.auto_translate*": {"queue": "translate"},
"weblate.accounts.tasks.notify_*": {"queue": "notify"},
"weblate.accounts.tasks.send_mails": {"queue": "notify"},
"weblate.utils.tasks.settings_backup": {"queue": "backup"},
"weblate.utils.tasks.database_backup": {"queue": "backup"},
"weblate.wladmin.tasks.backup": {"queue": "backup"},
"weblate.wladmin.tasks.backup_service": {"queue": "backup"},
"weblate.memory.tasks.*": {"queue": "memory"},
}
# Enable plain database backups
DATABASE_BACKUP = "plain"
# Enable auto updating
AUTO_UPDATE = False
# PGP commits signing
WEBLATE_GPG_IDENTITY = None
# Third party services integration
MATOMO_SITE_ID = None
MATOMO_URL = None
GOOGLE_ANALYTICS_ID = None
SENTRY_DSN = None
SENTRY_ENVIRONMENT = SITE_DOMAIN
AKISMET_API_KEY = None
管理命令
注解
在与运行 web 服务器的用户不同的用户下运行管理命令,可能会导致文件获得错误的权限,请查阅 文件系统权限 了解详情。
您会找到基本的管理命令(作为 Django 源中的 ./manage.py
来获得它,或者作为可安装在Weblate 顶层的脚本调用 weblate 中的扩展组来获得它 )。
调用管理命令
如上面所提到的,如何调用取决于您如何安装 Weblate。
如果使用 Virtualenv 来运行 Weblate ,那么您可以指定 weblate 的完整路径,或者在调用前激活 virtualenv :
# Direct invocation
~/weblate-env/bin/weblate
# Activating virtualenv adds it to search path
. ~/weblate-env/bin/activate
weblate
如果您直接使用源代码(来源于 tarball 或 Git checkout ),管理脚本可以在 Weblate 源文件的 ./manage.py
中获得。要运行它:
python ./manage.py list_versions
如果您使用 pip 或 pip3 安装程序,或使用 ./setup.py
脚本来安装 Weblate ,那么 weblate 安装到您的路径下(或者 virtualenv 路径下),您可以从那里用它控制 Weblate :
weblate list_versions
对于 Docker 镜像,脚本向上面一样安装,您可以使用 docker exec 来运行:
docker exec --user weblate <container> weblate list_versions
对于 docker-compose ,过程是相似的,您只是必须使用 docker-compose exec :
docker-compose exec --user weblate weblate weblate list_versions
在您需要向它传递文件的情况下,您可以临时添加卷:
docker-compose exec --user weblate /tmp:/tmp weblate weblate importusers /tmp/users.json
add_suggestions
- weblate add_suggestions <project> <component> <language> <file>
2.5 新版功能.
从文件导入翻译,用作给定翻译的建议。它会跳过重复的翻译;只会添加不同的内容。
- --author USER@EXAMPLE.COM
建议的作者电子邮箱地址。这个用户必须在导入前存在(您可以根据需要在管理界面建立一个)。
示例:
weblate --author michal@cihar.com add_suggestions weblate application cs /tmp/suggestions-cs.po
auto_translate
- weblate auto_translate <project> <component> <language>
2.5 新版功能.
在 4.6 版更改: 添加了翻译模式参数。
根据其他组件翻译进行自动翻译。
- --source PROJECT/COMPONENT
指定可用作翻译的来源的组件。如果不指定,将使用项目中的所有组件。
- --user USERNAME
指定列出的用户名,作为翻译的作者。如果不指定那么使用“匿名用户”。
- --overwrite
是否去覆盖现有的翻译。
- --add
如果给定的翻译不存在,自动添加语言。
- --mt MT
实用机器翻译而不是其他组件作为机器翻译。
- --threshold THRESHOLD
机器翻译的相似度阈值,默认为 80 。
- --mode MODE
Specify translation mode, default is
translate
butfuzzy
orsuggest
can be used.
示例:
weblate auto_translate --user nijel --inconsistent --source weblate/application weblate website cs
参见
celery_queues
- weblate celery_queues
3.7 新版功能.
显示 Celery 任务队列的长度。
checkgit
- weblate checkgit <project|project/component>
打印后端 Git 仓库的当前状态。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
commitgit
- weblate commitgit <project|project/component>
将任何可能待定的更改提交给后端 Git 仓库。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
commit_pending
- weblate commit_pending <project|project/component>
提交早于给定时间段的待定更改。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
注解
这由 Weblate 在后台自动执行,所以实际不需要手动调用,除了要强制早于 组件配置 指定的执行。
cleanuptrans
- weblate cleanuptrans
清理无主的检查和翻译建议。这通常不需要手动运行,因为清理在后台自动启动。
参见
cleanup_ssh_keys
- weblate cleanup_ssh_keys
4.9.1 新版功能.
Performs cleanup of stored SSH host keys:
Removes deprecated RSA keys for GitHub which might cause issues connecting to GitHub.
Removes duplicate entries in host keys.
参见
:ref`ssh-repos`
createadmin
- weblate createadmin
除非指定,否则用随机密码建立 admin
账户。
- --password PASSWORD
在命令行提供密码,而不要生成随机的。
- --no-password
不要设置密码,这对`–update`可能有用。
- --username USERNAME
使用给定的姓名而不是
admin
。
- --email USER@EXAMPLE.COM
指定 admin 的电子邮箱地址。
- --name
指定 admin 的姓名(可见的)。
- --update
更新现有的用户(您可以用这个来更改密码)。
在 2.9 版更改: 添加参数 --username
、 --email
、 --name
和 --update
。
dump_memory
- weblate dump_memory
2.20 新版功能.
将包含 Weblate 翻译记忆库内容的 JSON 文件导出。
参见
dumpuserdata
- weblate dumpuserdata <file.json>
通过 importuserdata
将 userdata 转储到文件供以后使用
提示
这在迁移或合并 Weblate 实例时会很方便。
import_demo
- weblate import_demo
4.1 新版功能.
根据 <https://github.com/WeblateOrg/demo> 使用组件来新建演示项目。
这在开发 Weblate 时会有用。
import_json
- weblate import_json <json-file>
2.7 新版功能.
根据 JSON 数据批量导入组件。
导入的 JSON 文件结构非常符合组件对象(请参见 GET /api/components/(string:project)/(string:component)/
)。您必须包括 name
和 filemask
字段。
- --project PROJECT
指定从哪里导入组件。
- --main-component COMPONENT
对所有的使用来自这个组件的给定版本控制系统(VCS)仓库。
- --ignore
跳过(已经)导入的组件。
- --update
更新(已经)导入的组件。
在 2.9 版更改: 那里的参数 --ignore
和 --update
用于处理已经导入的组件。
JSON 文件的例子:
[
{
"slug": "po",
"name": "Gettext PO",
"file_format": "po",
"filemask": "po/*.po",
"new_lang": "none"
},
{
"name": "Android",
"filemask": "android/values-*/strings.xml",
"template": "android/values/strings.xml",
"repo": "weblate://test/test",
"file_format": "aresource"
}
]
import_memory
- weblate import_memory <file>
2.20 新版功能.
将 TMX 或 JSON 文件导入 Weblate 翻译记忆库。
- --language-map LANGMAP
允许将 TMX 的语言映射到 Weblate 翻译记忆库。语言代码通常在 Weblate 进行规范化之后映射。
例如
--language-map en_US:en
将所有en_US
字符串作为en
字符串来导入。如果您的 TMX 文件的地区恰好与您在 Weblate 中使用的地区不匹配,这会很有用。
参见
import_project
- weblate import_project <project> <gitrepo> <branch> <filemask>
在 3.0 版更改: import_project 命令现在基于 组件发现 插件,导致一些行为的更改,并接受一些参数。
根据 filemask ,将组件批量导入项目。
<project> 将已存在的项目命名,组件将导入其中。
<gitrepo> 确定了要使用的 Git 仓库的 URL,而 <branch> 说明了 Git 分支。为了从现有的 Weblate 组件导入另外的翻译组件,使用 <gitrepo> 的 weblate://<project>/<component> URL 。
<filemask> 为仓库定义了文件发现。或者可以使用通配符来使它简单,或者可以使用正则表达式的全部功能。
简单的匹配对组件名称使用 **
,对语言使用 *
,例如: **/*.po
正则表达式必须包含组命名的 component 和 language 。例如: (?P<language>[^/]*)/(?P<component>[^-/]*)\.po
根据文件,导入与现有的组件匹配,并且添加不存在的那些。它不更改已经存在的那些。
- --name-template TEMPLATE
使用 Django 模板语法来定制组件的名称。
例如:
Documentation: {{ component }}
- --base-file-template TEMPLATE
为单语言翻译定制译文模板文件。
例如:
{{ component }}/res/values/string.xml
- --new-base-template TEMPLATE
为另外新的翻译定制译文模板文件。
例如:
{{ component }}/ts/en.ts
- --main-component
你可以指定哪个组件作为主组件——即真正包含版本控制系统(VCS)仓库的组件。
- --license NAME
指定整体、项目或组件翻译的许可。
- --license-url URL
指定翻译许可所在的 URL 。
- --vcs NAME
在需要指定使用哪个版本的轻质系统的情况下,您可以在这里进行。默认版本控制是 Git。
为了给出一些例子,让我们导入两个项目。
第一个是 Debian 手册翻译,那里的每种语言都有各自的文件夹,里面有 每个章节的翻译:
weblate import_project \
debian-handbook \
git://anonscm.debian.org/debian-handbook/debian-handbook.git \
squeeze/master \
'*/**.po'
然后 Tangaguru 工具,那里需要指定文件格式和译文模板文件,并且指定所有组件和翻译如何位于单一一个文件夹中:
weblate import_project \
--file-format=properties \
--base-file-template=web-app/tgol-web-app/src/main/resources/i18n/%s-I18N.properties \
tanaguru \
https://github.com/Tanaguru/Tanaguru \
master \
web-app/tgol-web-app/src/main/resources/i18n/**-I18N_*.properties
更复杂的例子是关于解析文件名而从文件名中得到正确的组件和语言,像 src/security/Numerous_security_holes_in_0.10.1.de.po
:
weblate import_project \
tails \
git://git.tails.boum.org/tails master \
'wiki/src/security/(?P<component>.*)\.(?P<language>[^.]*)\.po$'
筛选出指定的语言的翻译:
./manage import_project \
--language-regex '^(cs|sk)$' \
weblate \
https://github.com/WeblateOrg/weblate.git \
'weblate/locale/*/LC_MESSAGES/**.po'
导入 Sphinx 文档,分成多个文件:
$ weblate import_project --name-template 'Documentation: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/**.po'
导入 Sphinx 文档,分成多个文件和文件夹:
$ weblate import_project --name-template 'Directory 1: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/dir1/**.po'
$ weblate import_project --name-template 'Directory 2: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/dir2/**.po'
参见
更多具体的例子可以在 从国际化开始 章节找到,另外您会想要使用 import_json
。
importuserdata
- weblate importuserdata <file.json>
从 dumpuserdata
建立的文件中导入用户数据
importusers
- weblate importusers --check <file.json>
从 Django auth_users 数据库的 JSON 转储中导入用户。
- --check
使用这个选项可以检查给定文件是否可以被导入,并且报告用户名或电子邮箱地址可能导致的冲突。
可以从现有的 Django 安装中导出用户,这需要使用:
weblate dumpdata auth.User > users.json
install_addon
3.2 新版功能.
- weblate install_addon --addon ADDON <project|project/component>
将附加组件安装到一组组件中。
- --addon ADDON
要安装的附加组件名称。例如
weblate.gettext.customize
。
- --configuration CONFIG
以 JSON 编码的附加组件配置。
- --update
更新现有的附加组件配置。
可以或者定义将附加组件安装到哪个项目或组件中(例如 weblate/application
),或者使用 --all
来包括所有现有的组件。
为所有的组件安装 自定义 gettext 输出 :
weblate install_addon --addon weblate.gettext.customize --config '{"width": -1}' --update --all
参见
list_languages
- weblate list_languages <locale>
列出 MediaWiki 标记中支持的语言——语言代码、英语名称和本地化名称。
这用来生成 <https://wiki.l10n.cz/Slovn%C3%ADk_s_n%C3%A1zvy_jazyk%C5%AF>.
list_translators
- weblate list_translators <project|project/component>
按给定项目的语言列出为对应语言作贡献的翻译者:
[French]
Jean Dupont <jean.dupont@example.com>
[English]
John Doe <jd@example.com>
- --language-code
用语言代码而不是语言来列出名称。
可以或者定义使用哪个项目或组件(例如 weblate/application
),或者使用 --all
从所有现存的组件中列出翻译者。
list_versions
- weblate list_versions
列出所有 Weblate 依赖项及其版本。
loadpo
- weblate loadpo <project|project/component>
从磁盘重新加载翻译(例如,您在版本控制系统(VCS)仓库中进行了一些更新)。
- --force
强制更新,即使文件应该是更新的。
- --lang LANGUAGE
将处理限制为单一语言。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
注解
你很少需要调用这个命令,Weblate 会在每次版本控制系统(VCS)更新时自动加载更改的文件。如果您手动更改了 Weblate 的底层版本控制系统(VCS)仓库,或者在升级后的某些特殊情况下,则需要调用这个命令。
lock_translation
- weblate lock_translation <project|project/component>
防止进一步翻译组件。
提示
在您想要对下层仓库进行一些维护时有用。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
move_language
- weblate move_language source target
3.0 新版功能.
允许您合并语言内容。当更新到新版本,这个新版本对使用 (generated) 前缀建立的之前未知的语言包含别名时,这会有用。它将所有内容从 source 语言移动到 target 语言。
示例:
weblate move_language cze cs
移动内容后,您应该检查是否有什么落下了(这是因为有人在同时更新仓库而导致的竞争情况),并且要删除 (generated) 语言。
pushgit
- weblate pushgit <project|project/component>
将提交的更改推送到上游的版本控制系统(VCS)仓库。
- --force-commit
在推送前,强制执行任何待定的更改。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
注解
如果开启了 组件配置 中的:ref:component-push_on_commit,Weblate 会自动推送更改,这是默认的。
unlock_translation
- weblate unlock_translation <project|project/component>
将给定的组件解锁,使它能够被翻译。
提示
在您想要对下层仓库进行一些维护时有用。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
setupgroups
- weblate setupgroups
配置默认组,并可选地将所有用户指定到那个默认组中。
- --no-privs-update
关闭对现有组的自动更新(只添加新的)。
参见
setuplang
- weblate setuplang
将 Weblate 中的确定语言的列表更新。
- --no-update
关闭现有语言的自动更新(只添加新的)。
updatechecks
- weblate updatechecks <project|project/component>
更新对所有字符串的所有检查。
提示
对检查进行主要更改的更新是有用的。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
updategit
- weblate updategit <project|project/component>
取回远程版本控制系统(VCS)仓库并更新内部缓存。
您可以确定或者哪个项目或组件要更新(例如 weblate/application
),或者使用 --all
来更新所有现有组件。
公告
在 4.0 版更改: 在此前的发布版本中,这个特性被称为白板消息。
通过张贴网站范围的,每个项目、组件或语言的公告,向翻译者提供信息。
宣布翻译的目的、截止日期、状态或特定目标。
用户可以接收到关注项目公告的通知(除非用户选择关闭)。
这会用于从发布网站的目的到指定翻译的目标的各种事情。
公告可以通过 Manage 菜单中的 Post announcement 在每一层级发布:

还可以使用管理界面添加:

然后根据特定的上下文显示公告:
没有特定的上下文
显示在控制面板(登录页面)上。
特定项目
项目内显示,包括其所有的组件和翻译。
特定组件
对于给定的组件机器翻译来显示。
特定语言
显示在语言的概览和该语言的全部翻译中。
这就是语言概览页面上的样子:

组件列表
指定多个组件列表,作为显示在用户控制面板上的选项,用户可以从中挑选一个作为默认视图。请参阅 控制面板 了解更多信息。
在 2.20 版更改: 控制面板上出现的每个组件列表都会显示一个状态。
可以在管理界面的 组件列表 部分指定组件列表的名称和内容。每个组件列表必须有一个显示给用户的名称,和一个在 URL 中代表它的标识串。
在 2.13 版更改: 从管理界面更改匿名用户的控制面板设置,修改控制面板向未经身份验证用户展示的内容。
自动组件列表
2.13 新版功能.
通过建立 Automatic component list assignment 规则,根据其标识串自动将组件添加到列表中。
这对于维护大型安装的组件列表很有用,或者你想在 Weblate 安装中拥有一个包含所有组件的组件列表。
提示
制作一个包含你的 Weblate 安装时的所有组件的组件列表。
1. Define Automatic component list assignment with ^.*$
as regular expression
in both the project and the component fields, as shown on this image:

可选的 Weblate 模块
可以获得几个可选的模块来配置您的设置。
Git 导出器
2.10 新版功能.
使用 HTTP(S) 为您提供对底层 Git 仓库的只读访问。
安装
将
weblate.gitexport
添加到settings.py
中安装的 apps 中:
INSTALLED_APPS += ("weblate.gitexport",)
通过安装后迁移数据库,将现有的仓库导出:
weblate migrate
用法
模块自动钩入 Weblate,并且在 组件配置 中设置导出仓库 URL。仓库在 Weblate URL的 /git/
部分下是可以访问的,例如 https://example.org/git/weblate/main/
。
公共可用项目的仓库可以被克隆而无需认证:
git clone 'https://example.org/git/weblate/main/'
对存储库的受限制的访问(使用 Private access control 或在 REQUIRE_LOGIN
处于启用状态时)需要一个 API 令牌,获取位置在你的 用户个人资料:
git clone 'https://user:KEY@example.org/git/weblate/main/'
提示
成员或 Users 用户组与匿名用户默认通过 Access repository 和 Power user 角色访问公开项目。
账单
2.4 新版功能.
这用在 Hosted Weblate 上来确定付费套餐,跟踪收据和使用限制。
安装
1. Add weblate.billing
to installed apps in
settings.py
:
INSTALLED_APPS += ("weblate.billing",)
运行数据库迁移,来可选地为模块安装另外的数据库结构:
weblate migrate
用法
安装后您可以在管理界面控制账单。启用了账单模块的用户将在 TA 们的 用户个人资料 中看到新的 Billing 选项卡。
账单模块额外允许项目管理员不是超级用户的情况下去新建新的项目和组件(请参见 添加翻译项目和组件)。当后面的条件满足是这是可能的:
账单在其配置的限制下(任何过度的使用都会阻止新建项目/组件),并且被支付(如果价格为非零值的话)
用户是现有的带有账单项目的管理员,或者用户是账单的所有者(当为用户新建新的账单,而允许导入新的项目时,后者是必要的)。
在新建项目时,用户在访问多个账单的情况下,能够选择将项目记在哪个账单上。
法律声明
2.15 新版功能.
这用在 Hosted Weblate 上,来提供所需的法律文件。它开始时提供空白文档,会希望您填充文档中后面的模板:
legal/documents/tos.html
服务条款文档
legal/documents/privacy.html
隐私政策文档
legal/documents/summary.html
服务条款与隐私政策的简短概况
注解
可以在这个 Git 仓库 <https://github.com/WeblateOrg/wllegal/tree/main/wllegal/templates/legal/documents> 中获取 Hosted Weblate 的法律文件。
这些很可能对您没有直接的用处,但如果调整来满足您的需求时,以此作为起点可能会比较方便。
安装
1. Add weblate.legal
to installed apps in
settings.py
:
INSTALLED_APPS += ("weblate.legal",)
# Optional:
# Social auth pipeline to confirm TOS upon registration/subsequent sign in
SOCIAL_AUTH_PIPELINE += ("weblate.legal.pipeline.tos_confirm",)
# Middleware to enforce TOS confirmation of signed in users
MIDDLEWARE += [
"weblate.legal.middleware.RequireTOSMiddleware",
]
运行数据库迁移,来可选地为模块安装另外的数据库结构:
weblate migrate
编辑
weblate/legal/templates/legal/
文件夹中的而法律文件,与您的服务匹配。
用法
安装并编辑后,法律文件显示在 Weblate 界面中。
头像
头像在服务器端下载并缓存,来减少对默认服务的网站的泄露。通过为其配置的电子邮件地址来取回头像的内建支持,可以使用 ENABLE_AVATARS
来关闭。
当前的 Weblate 支持:
针对垃圾邮件的保护
你可以免受用户发送垃圾邮件的侵扰,方法是使用 Akismet 服务。
Install the akismet Python module (this is already included in the official Docker image).
获取 Akismet API 密钥。
Store it as
AKISMET_API_KEY
orWEBLATE_AKISMET_API_KEY
in Docker.
Following content is sent to Akismet for checking:
来自未经身份验证用户的建议
项目和组件描述及链接
注解
这(除了其它事情以外)依赖于客户端的 IP 地址,适当的配置请参见: 在反向代理后面运行 。
使用 GnuPG 为 Git 提交签名
3.1 新版功能.
所有的提交均可由 Weblate 实例的 GnuPG 密钥为其签名。
1. Turn on WEBLATE_GPG_IDENTITY
. (Weblate will generate a GnuPG
key when needed and will use it to sign all translation commits.)
此功能需要安装 GnuPG 2.1 或更新版本。
您可以在 DATA_DIR
中找到密钥,公钥显示在“关于”页面上:

2. Alternatively you can also import existing keys into Weblate, just set
HOME=$DATA_DIR/home
when invoking gpg.
频次限制
在 3.2 版更改: 频次限制先择接受更细粒度的配置。
在 4.6 版更改: The rate limiting no longer applies to superusers.
Weblate 的一些操作受到频次限制。在 RATELIMIT_WINDOW
的秒数内最多允许 RATELIMIT_ATTEMPTS
次数的尝试。然后阻止用户 RATELIMIT_LOCKOUT
时间。还有指定范围的设置,例如 RATELIMIT_CONTACT_ATTEMPTS
或 RATELIMIT_TRANSLATE_ATTEMPTS
。下面的表格是可用范围的完整列表。
后面的操作受到频次限制:
名称 |
范围 |
允许的尝试 |
频次限制窗口 |
锁定时间 |
---|---|---|---|---|
注册 |
|
5 |
300 |
600 |
将消息发送给管理员 |
|
5 |
300 |
600 |
登录时的密码验证 |
|
5 |
300 |
600 |
网站范围的搜索 |
|
6 |
60 |
60 |
翻译 |
|
30 |
60 |
600 |
添加到术语表 |
|
30 |
60 |
600 |
开始翻译到一种新语言 |
|
2 |
300 |
600 |
创建新项目 |
|
5 |
600 |
600 |
如果用户没能在 AUTH_LOCK_ATTEMPTS
的次数内登录,那么账户的密码验证将关闭,直到完成了重置密码过程为止。
The settings can be also applied in the Docker container by adding WEBLATE_
prefix to the setting name, for example RATELIMIT_ATTEMPTS
becomes WEBLATE_RATELIMIT_ATTEMPTS
.
API 具有另外的速率限制设置,请参见 API 频次限制。
Fedora Messaging 集成
Fedora Messaging is AMQP-based publisher for all changes happening in Weblate. You can hook additional services on changes happening in Weblate using this.
The Fedora Messaging integration is available as a separate Python module
weblate-fedora-messaging
. Please see
<https://github.com/WeblateOrg/fedora_messaging/> for setup instructions.
定制 Weblate
使用 Django 和 Python 进行扩展和定制。将你的更改贡献给上游,让每个人都能受益。这降低了您的维护成本;当改变内部接口或重构代码时,Weblate 的代码会被照顾到。
警告
内部界面与模板都不被认为是稳定的 API 。请对每次升级都复查自己的定制,接口或其语义可能未经通知就进行更改。
建立 Python 模块
如果不熟悉 Python ,你可以查看 Python For Beginners ,它解释了其基本内容并指向了高级教程。
为了写出一些定制 Python 代码(被称为模块),需要一个地方进行存储,或者在系统路径(通常像 /usr/lib/python3.7/site-packages/
的地方),或者在 Weblate 目录下,同样也添加到解释程序搜索路径下。
更好地是,将你的定制化转变为适当的 Python 包:
为你的包建立文件夹(我们会使用 weblate_customization )。
在里面新建`setup.py` 文件来描述包:
from setuptools import setup setup( name="weblate_customization", version="0.0.1", author="Your name", author_email="yourname@example.com", description="Sample Custom check for Weblate.", license="GPLv3+", keywords="Weblate check example", packages=["weblate_customization"], )
建立定制代码的 Python 模块( 也被成为
weblate_customization
)的文件夹。在里面建立
__init__.py
文件来确认 Python 可以导入模块。现在可以使用 pip install -e 安装这个包。更多信息可以在 “Editable” Installs 中找到。
模块一旦安装,就可以用在 Webalte 配置中(例如
weblate_customization.checks.FooCheck
)。
你的模块结构应该看起来像这样:
weblate_customization
├── setup.py
└── weblate_customization
├── __init__.py
├── addons.py
└── checks.py
可以在 <https://github.com/WeblateOrg/customize-example> 找到定制 Weblate 的例子,它涵盖了下面描述的所有题目。
更改标志
建立简单的 Django app 来包含想要覆盖的静态文件(请参见 建立 Python 模块 )。
品牌出现在后面的文件中:
icons/weblate.svg
导航栏中显示的标志 。
logo-*.png
网页图标取决于屏幕分辨率和浏览器。
favicon.ico
传统浏览器使用的网页图标。
weblate-*.png
机器人或匿名用户使用的头像。一些浏览器将这些图标用作快捷方式图标。
email-logo.png
在通知电子邮件中使用。
把它添加到:setting:django:INSTALLED_APPS:
INSTALLED_APPS = ( # Add your customization as first "weblate_customization", # Weblate apps are here… )
运行
weblate collectstatic --noinput
,来收集提供给客户端的静态文件。
定制的质量检查、插件和自动修复
要在 Weblate 中安装你的 定制的自动修正,编写自己的检查 或 编写附加组件 代码:
将文件放进你的包含 Weblate 定制的 Python 模块中(请参见 建立 Python 模块 )。
在专用设置(
WEBLATE_ADDONS
、CHECK_LIST
或AUTOFIX_LIST
)中将其完全合法的路径添加到 Python 类中:
# Checks
CHECK_LIST += ("weblate_customization.checks.FooCheck",)
# Autofixes
AUTOFIX_LIST += ("weblate_customization.autofix.FooFixer",)
# Add-ons
WEBLATE_ADDONS += ("weblate_customization.addons.ExamplePreAddon",)
管理界面
管理界面在 /manage/
下面提供管理设置。它对于具有管理特权的登录用户是可用的,通过使用右上角的扳手图标来访问:

它包括您 Weblate 的基本视图:
支持状态,请参见 从 Weblate 获取支持
备份,请参见 备份和移动 Weblate
共享的翻译记忆库,见 翻译记忆库
性能报告,来复查 Weblate 的健康状况和 Celery 队列的长度
SSH 密钥管理,见 SSH 仓库
所有组件的警报概述,见 翻译组件警报
Django 管理界面
警告
将来会删除,因为其应用困难——多数特性可以直接在 Weblate 中管理。
可以在这里管理数据库中存储的对象,如用户、翻译和其他设置:

在 Reports 部分,可以检查网站的状态,为 生产设置 进行调整,或者管理用于访问的 SSH 密钥 Accessing repositories 。
管理任意部分下的数据库对象。最有趣的也许是 Weblate translations ,你可以在这里管理可翻译的项目,请参见 项目配置 和 组件配置 。
Weblate languages 保持语言定义,在 语言定义 中进一步解释。
添加项目
添加项目作为所有组件的容器。通常可以为一部分软件或图书(各自参数的信息请参见 项目配置 )来建立一个项目:

参见
双语组件
一旦添加了一个项目,就可以添加翻译组件了。(关于各自参数的信息,请参见 组件配置 ):

单语言组件
为了使这些翻译更容易,提供了模板文件,包含了各自源语言的对应信息 ID(通常为英语)。(对于各自参数的信息,请参见 组件配置):

从 Weblate 获取支持
Weblate 是一款 copylefted 的自由软件,由社区进行支持。订阅者无需支付额外费用便可以获得优先的支持;预付支持服务包可供所有人使用。您可以在 <https://weblate.org/support/> 找到更多关于当前支持服务的信息。
集成支持
3.8 新版功能.
你可以视需要将购买的支持包集成进 Weblate 订阅管理 界面,您可以在那里找到所购支持包的链接。关于安装的基本实例细节也会以这种方式报告给 Weblate。

提交给 Weblate 的数据
配置 Weblate 实例的 URL
您的网站标题
您运行的 Weblate 版本
您 Weblate 数据库中一些对象的记录(项目、组件、语言、源字符串和用户)
您实例的 SSH 公钥
Additionally, when 发现 Weblate is turned on:
List of public projects (name, URL and website)
没有提交其它数据。
集成服务
查看您的支持包是否合法
提示
购买的支持包在购买时已经激活,并且不必集成它们就可以使用。
发现 Weblate
4.5.2 新版功能.
注解
该功能目前处于早期测试阶段。
Discover Weblate is an opt-in service that makes it easier for users to find Weblate servers and communities. Users can browse registered services on <https://weblate.org/discover/>, and find there projects to contribute.
列入
提示
Participating in Discover Weblate makes Weblate submit some information about your server, please see 提交给 Weblate 的数据.
To list your server with an active support subscription (see 集成支持) in Discover Weblate all you need to do is turn this on in the management panel:

Listing your server without a support subscription in Discover Weblate:
注册 Weblate,注册地址 <https://weblate.org/user/>
在发现数据库注册你的 Weblate 服务器,注册地址<https://weblate.org/subscription/discovery/>
Confirm the service activation in your Weblate and turn on the discovery listing in your Weblate management page using Enable discovery button:

定制列表
You can customize the listing by providing a text and image (570 x 260 pixels) at <https://weblate.org/user/>.
法律文件
注解
Herein you will find various legal information you might need to operate Weblate in certain legal jurisdictions. It is provided as a means of guidance, without any warranty of accuracy or correctness. It is ultimately your responsibility to ensure that your use of Weblate complies with all applicable laws and regulations.
ITAR and other export controls
Weblate can be run within your own datacenter or virtual private cloud. As such, it can be used to store ITAR or other export-controlled information, however, end users are responsible for ensuring such compliance.
The Hosted Weblate service has not been audited for compliance with ITAR or other export controls, and does not currently offer the ability to restrict translations access by country.
US encryption controls
Weblate does not contain any cryptographic code, but might be subject export controls as it uses third party components utilizing cryptography for authentication, data-integrity and -confidentiality.
Most likely Weblate would be classified as ECCN 5D002 or 5D992 and, as publicly available libre software, it should not be subject to EAR (see Encryption items NOT Subject to the EAR).
Software components used by Weblate (listing only components related to cryptographic function):
- Python
See https://wiki.python.org/moin/PythonSoftwareFoundationLicenseFaq#Is_Python_subject_to_export_laws.3F
- GnuPG
Optionally used by Weblate
- Git
Optionally used by Weblate
- curl
Used by Git
- OpenSSL
Used by Python and cURL
The strength of encryption keys depends on the configuration of Weblate and the third party components it interacts with, but in any decent setup it will include all export restricted cryptographic functions:
In excess of 56 bits for a symmetric algorithm
Factorisation of integers in excess of 512 bits for an asymmetric algorithm
Computation of discrete logarithms in a multiplicative group of a finite field of size greater than 512 bits for an asymmetric algorithm
Discrete logarithms in a group different than above in excess of 112 bits for an asymmetric algorithm
Weblate doesn’t have any cryptographic activation feature, but it can be configured in a way where no cryptography code would be involved. The cryptographic features include:
使用安全传输协议(HTTPS)访问远程服务器
为代码的提交生成签名(PGP)
从国际化开始
有一个项目,想把它翻译成多种语言?本指南将帮助你做到这一点。其中展示了几种典型情况,但大多数示例都是通用的,也可以用于其他情景。
在翻译任何软件之前,要认识到世界各处的语言真正不同,而您不应该根据自己的经验做出任何假设。对于多数语言,如果尝试从翻译的段落中连接出句子,看起来会很奇怪。应该正常滴处理复数形式,因为很多语言对此具有复杂的规则,最终使用的国际化框架应该支持它。
最后但同样重要的是,有时可能需要在翻译的字符串中添加一些上下文。想象一下翻译者要翻译字符串 Sun
。没有上下文的话多数人会将它翻译为离我们最近的恒星,但实际上它可能被用作星期日的缩写。
选择国际化框架
选择你平台上的标准格式,尽量避免重复发明轮子,避免通过创建你自己的框架来处理本地化问题。Weblate 支持大多数广泛使用的框架,更多信息请参见 支持的文件格式 (特别是 翻译类型功能 )。
我们对一些平台的个人推荐在下面的表格中。这基于我们的经验,但这无法覆盖所有的使用情况,因此做选择时总是要考虑您的环境。
平台 |
推荐的格式 |
---|---|
Android |
|
iOS |
|
Qt |
|
Python |
|
PHP |
|
C/C++ |
|
C# |
|
Perl |
|
Ruby |
|
Web 扩展 |
|
Java |
|
JavaScript |
- 1
PHP 对 Gettext 的原生支持是有问题的,并且在 Windows 构建中经常丢失,建议使用第三方库 motranslator 来代替。
- 2
如果不需要复数的话还可以使用 Java 属性。
- 3
如果不需要复数的话还可以使用简单的 JSON 文件。
一些格式更具体的工作流程在后面的章节中描述:
参见
与 Weblate 集成
Weblate 基础知识
项目和组件架构
在 Weblate 中, 翻译组织成为项目和组件。每个项目可以包含几个组件,并且组件包含各个语言的翻译。组件相应于一个翻译文件(例如 GNU gettext 或 Android 字符串资源)。项目帮助您将组件组织为逻辑的组(例如,将一个应用中使用的所有翻译分组)。
默认情况下,每个项目内都有对跨组件传播的公共字符串的翻译。这减轻了重复和多版本翻译的负担。但假如翻译应当有所不同,可以使用 允许同步翻译 通过 组件配置 禁用翻译传播。
将本地化项目导入 Weblate
Weblate 在开发时一直注意将版本管理系统(VCS)集成作为核心功能。因此,最简单的方法是授予 Weblate 访问存储库的权限。导入过程将指导您将翻译配置进组件。
或者,您可以使用 Weblate 设置一个包含所有翻译的本地存储库,无需集成。
从 Weblate 获取更新的翻译
为了从 Weblate 取回更新的字符串,可以简单地取回基础的Git仓库(要么来自文件系统,要么可以通过 git-exporter`来获得)。在这之前,您会想要提交任何挂起的更改(请参见 :ref:`lazy-commit)。这可以通过(在 Repository maintenance 中)或使用 Weblate 客户端 从命令行来实现。
如果你向 Weblate 授予了对仓库的推送访问,并配置了 组件配置 中的 代码库推送 URL,此操作可以自动进行。见 推送 Weblate 的更改。
另外,您还可以使用 Weblate 的 REST API 来更新翻译以匹配最新版本。
将远程更改获取到 Weblate
为了将仓库中更新的字符串获取到 Weblate,只要从上游仓库拉取就可以了。这可以在用户界面(在 Repository maintenance 中)或使用 Weblate 客户端 从命令行来实现。
这可以通过在你的存储库中设置一个 webhook 来自动实现,每当有新的提交时,webhook 就会触发 Webate。更多细节请参见 更新仓库。
如果你没在用一个版本管理系统(VCS)集成,可以使用 UI 或 Weblate 的 REST API 来更新翻译,从而与您的码基匹配。
添加新字符串
如您的翻译文件与代码一起存储在一个版本控制系统(VCS)中,您很可能有一个现有的工作流供开发人员引入新的字符串。任何添加字符串的方法都将被采用,但请考虑使用 Quality gateway for the source strings 以避免引入错误。
当翻译文件与代码分离时,可以通过以下方法将新字符串引入 Weblate。
手动,在翻译源语言的 工具 菜单中使用 添加新翻译字符串。
通过编程,使用 API
POST /api/translations/(string:project)/(string:component)/(string:language)/units/
.通过上传源文件 替换现有翻译文件 (这将覆盖现有的字符串,所以请确保文件包括新旧字符串)或 Add new strings,请参见 导入方式。
注解
Availability of adding strings in Weblate depends on 管理字符串.
更新目标语言文件
对于单语言文件(请参见 支持的文件格式),Weblate 也许会添加不在 单语言译文模版语言文件 和实际翻译中的新翻译字符串。然而它不会对任何旧的字符串执行自动清理,因为那会具有难以预料的结果。如果想做的话,请安装附加组件 清理翻译文件 根据您的要求处理清理工作。
Weblate 也不会尝试以任何方式更新双语文件,所以如果需要 po
文件从 pot
更新的话,需要您自己通过使用 Update source strings 导入方式 或 更新 PO 文件以匹配 POT 文件 (msgmerge) 附加组件来实现。
管理版本控制仓库
Weblate stores all translation the version control repository. It can be either connected to upstream one, or it can be only internal. The Repository maintenance lets you manipulate with the repository.
提示
With 持续本地化 the repository is automatically pushed whenever there are changes and there is usually no need to manually manipulate with it.

下列操作可用:
Commit
提交任何在 Weblate 数据库中且不在代码库中的挂起更改,见 惰性提交。
Push
如通过 代码库推送 URL 进行了配置,则将更改推送到上游代码库。
Update, Pull, Rebase
Updates Weblate repository with upstream changes. It uses 合并方式 when choosing Update or you can choose different one from the dropdown menu.
Lock
锁定防止翻译者进行更改
Reset from Maintenance
Resets any changes done in Weblate to match upstream repository. This will discard all translations done in Weblate and not present in the upstream repository.
Cleanup from Maintenance
Removes untracked files from the repository. These could be result of misbehaving add-ons or bugs.
Force synchronization from Maintenance
Forces writing all strings to the translation files. Use this when repository files became out of sync with Weblate for some reason.
使用 GNU gettext 来翻译软件
GNU gettext 是使用最广泛的自由软件国际化工具之一。它为软件的本地化提供了一种简单而灵活的方法。它对复数有很好的支持,可以为已翻译字符串添加更多的上下文,并且有很多围绕它构建的工具。当然,它在 Weblate 中有很好的支持(请参见 GNU gettext 文件格式说明)。
注解
如果您打算在专有软件中使用它,请先查阅许可证,它可能不适合您。
GNU gettext 可以用于多种语言(C、Python、PHP、Ruby、JavaScript 等等),通常 UI 框架已经对其提供了一些支持。标准用法是通过 gettext() 函数调用,该函数通常具有 _() 别名,以使代码更简单易读。
此外,它提供了 pgettext() 调用,可用于为翻译者提供更多的上下文;还提供了 ngettext(),可以处理目标语言定义的复数类型。
作为广泛传播的工具,它具有很多封装,使其使用相当简单,你也许会想尝试其中之一,例如 intltool,而非下面描述的对 gettext 的手动调用。
工作流程概览
GNU gettext 使用几个文件来管理本地化工作:
PACKAGE.pot
包含从您的源代码中提取的字符串,典型地使用 xgettext 或一些高级封装,如 intltool。LANGUAGE.po
包含翻译为单一语言的字符串。一旦PACKAGE.pot
更新,那么必须由 msgmerge 来更新它。您可以使用 msginit 或在 Weblate 内新建新的语言文件。LANGUAGE.mo
包含LANGUAGE.po
的二进制表达,并且应用运行时使用。它典型地并不保持在版本控制之下,但在编译时使用 msgfmt 生成。在您想要使它处于版本控制中时,可以使用 生成 MO 文件 插件在 Weblate 中生成它。
GNU gettext 总体工作流程如下所示:
示例程序
使用 gettext 的 C 语言简单程序看起来会像后面这样:
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int count = 1;
setlocale(LC_ALL, "");
bindtextdomain("hello", "/usr/share/locale");
textdomain("hello");
printf(
ngettext(
"Orangutan has %d banana.\n",
"Orangutan has %d bananas.\n",
count
),
count
);
printf("%s\n", gettext("Thank you for using Weblate."));
exit(0);
}
提取可翻译的字符串
一旦您具有了使用 gettext 调用的代码,您可以使用 xgettext 从中提取消息,并将它们存储在 .pot 中:
$ xgettext main.c -o po/hello.pot
注解
有另外的程序从代码中提取字符串,例如 pybabel。
这新建了模板文件,您可以用它来开始新的翻译(使用 msginit),或在代码更改后更新现有的翻译(为此您将使用 msgmerge)。结果文件是简单的结构化文本文件:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-23 11:02+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: main.c:14
#, c-format
msgid "Orangutan has %d banana.\n"
msgid_plural "Orangutan has %d bananas.\n"
msgstr[0] ""
msgstr[1] ""
#: main.c:20
msgid "Thank you for using Weblate."
msgstr ""
每个 msgid
行定义了要翻译的字符串,在开始的特殊空字符串是包含关于翻译的元数据的文件标头。
开始新的翻译
在模板就位后,我们就可以开始我们的第一个翻译了:
$ msginit -i po/hello.pot -l cs --no-translator -o po/cs.po
Created cs.po.
刚刚新建的 cs.po
已经有一些信息填充进去了。最重要的是它获得了所选择的语言的适当复数形式定义,并且您可以看到几种复数已经根据它更改了:
# Czech translations for PACKAGE package.
# Copyright (C) 2015 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Automatically generated, 2015.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-23 11:02+0200\n"
"PO-Revision-Date: 2015-10-23 11:02+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: cs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ASCII\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
#: main.c:14
#, c-format
msgid "Orangutan has %d banana.\n"
msgid_plural "Orangutan has %d bananas.\n"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""
#: main.c:20
msgid "Thank you for using Weblate."
msgstr ""
这个文件被编译为优化的二进制形式,.mo 文件,由 GNU gettext 函数在运行时使用。时使用。
更新字符串
一旦在您的程序中添加了更多的字符串或更改了一些字符串,您再次执行 xgettext ,生成模板文件:
$ xgettext main.c -o po/hello.pot
然后您可以更新各自的翻译文件来匹配新建的模板(这包括重新排序字符串,赖于新的模板匹配):
$ msgmerge --previous --update po/cs.po po/hello.pot
导入到 Weblate
为了将这样的翻译导入 Weblate,当新建组件时,所有需要您定义的是后面的字段(字段的具体描述请参见 组件配置):
字段 |
值 |
---|---|
源代码库 |
您的项目的版本控制系统(VCS)仓库的 URL |
文件掩码 |
|
新翻译的译文模版 |
|
文件格式 |
选择 gettext PO file |
新语言 |
选择 创建新语言文件 |
就这样,现在您可以开始翻译您的软件了!
参见
你可以在 GitHub 上的 Weblate Hello 项目中找到包含多种语言的 gettext 示例:<https://github.com/WeblateOrg/hello>。
使用 Sphinx 翻译文档
Sphinx 是创建优美文档的工具。它使用了简单的 reStructuredText 语法,并以多种格式输出。如果要找个示例,那么本文档也是用它来构建的。使用 Sphinx 的非常有用的伴侣是 Read the Docs 服务,它会免费构建并出版您的文档。
我不会聚焦在撰写文档本身,如果您需要指导的话,只需要按照 Sphinx 网站上的指示即可。一旦准备好文档,将其翻译是非常容易地,因为 Sphinx 带有对此的支持,并且在其 国际化 中覆盖得很好。这只不过是一些配置指令并调用 sphinx-intl
工具的事。
如果使用 Read the Docs 服务,那么可以在 Read the Docs 上开始构建翻译的文档。它们的 Localization of Documentation 几乎覆盖了您需要的每一件事——创建另一个项目,设置其语言以及从主项目上链接它作为翻译。
现在您只需要翻译文档内容。Sphinx 会为每个目录或顶层文件生成 PO 文件,这导致需要翻译非常多的文件(取决于 gettext_compact
设置)。您可以将 index.po
导入 Weblate 作为初始组件,然后配置 组件发现 插件,来自动发现所有其它组件。
|
|
|
|
|
|
gettext PO 文件 |
|
|
用于匹配翻译文件的正则表达式 |
|
自定义组件名称 |
|
为新的翻译条目指定译文模版文件 |
|
提示
您希望 Sphinx 生成只是单一的 PO 文件吗?从 Sphinx 3.3.0 开始可以实现,使用:
gettext_compact = "docs"
你可以发现有几个文档项目就在使用这种方法进行自身的本地化翻译工作:
Weblate 文档 (您现在就在阅读这个文档)
使用 Weblate CDN 翻译 HTML 和 JavaScript
从 Weblate 4.2 开始能够使用 JavaScript 本地化 CDN 插件将本地化导出到 CDN。
注解
此功能在 Hosted Weblate 上是配置好的。它需要在安装时进行额外的配置,见 LOCALIZE_CDN_URL
和 LOCALIZE_CDN_PATH
。
在安装到您的组件中式,它将提交的翻译推送到 CND(请参见 惰性提交),而这些可以在您的 web 页面上使用来将其本地化。
创建组件中
首先您需要新建单语言组件,它将保持您的字符串,其一般指示请参见 添加翻译项目和组件。
在您已有仓库来开始的情况下(例如一个包含 HTML 文件的仓库),在仓库中为源语言新建空的 JSON 文件(请参见 源语言),例如 locales/en.json
。内容应该是``{}`` ,来指示空的对象。一旦具有了它,仓库就可以导入到 Weblate 中,而您可以通过配置插件来开始。
提示
在您已有翻译的情况下,您可以将其放置在语言 JSON 文件中,而那些将在 Weblate 中使用。
对于那些不想要使用(或不具有)现有仓库的人,当新建组件时选择 Start from scratch ,并选择 JSON file 作为文件格式(这是选择任何单语言格式都可以)。
正在配置 Weblate 内容分发网络附加组件
JavaScript 本地化 CDN 插件提供了一些配置选项。
- 翻译阈值
在这个阈值之上的翻译将包含在 CDN 中。
- CSS选择器
配置 HTML 文档中的哪些字符串是可翻译的,请参见 Weblate 内容分发网络的字符串提取 和 使用 Weblate 内容分发网络对 HTML 进行本地化操作。
- 语言cookie名称
包含用户所选择的语言的 cookie 的名称。在JavaScript 代码段中用于 使用 Weblate 内容分发网络对 HTML 进行本地化操作。
- 从 HTML 文件里提取字符串
仓库中文件的列表,或 Weblate 寻找可翻译字符串并提供它们用于翻译的 URLs,请参见 Weblate 内容分发网络的字符串提取。
Weblate 内容分发网络的字符串提取
翻译字符串必须在 Weblate 中出现。可以手动管理,使用 API 来建立,或使用 Extract strings from HTML files 列出文件或 URL ,Weblate 会自动提取它们。文件必须出现在残酷中,或者包含远程 URL ,由 Weblate下载并规则地分析。
CSS selector 的默认配置提取 CSS class l10n
的元素,例如从后面的一段中提取两个字符串:
<section class="content">
<div class="row">
<div class="wrap">
<h1 class="section-title min-m l10n">Maintenance in progress</h1>
<div class="page-desc">
<p class="l10n">We're sorry, but this site is currently down for maintenance.</p>
</div>
</div>
</div>
</section>
在不想修改现有代码的情况下,还可以使用 *
作为选择器处理所有元素。
注解
目前只有元素的文本被提取。这个附加组件不支持元素属性或具有子类的元素的本地化。
使用 Weblate 内容分发网络对 HTML 进行本地化操作
为了将 HTML 文档本地化,需要加载 weblate.js
脚本:
<script src="https://weblate-cdn.com/a5ba5dc29f39498aa734528a54b50d0a/weblate.js" async></script>
加载时,会自动发现所有匹配的翻译元素(基于 CSS selector ),并用翻译替换其文本。
从配置的 cookie 检测到用户语言,并退回到在浏览器中配置的用户首选语言。
Language cookie name 可以用于与其它应用集成(例如当使用 Django 时选择 django_language
)。
JavaScript本地化
单独的翻译在内容分发网络下暴露为双语 JSON 文件。要获取一个,你可以使用以下代码:
fetch(("https://weblate-cdn.com/a5ba5dc29f39498aa734528a54b50d0a/cs.json")
.then(response => response.json())
.then(data => console.log(data));
在这种情况下需要采用实际的本地化逻辑。
翻译组件警报
为任何给定的翻译组件在 Weblate 配置或翻译项目中显示错误。还提供了如何将找到的问题定位的指南。
当前覆盖后面的内容:
翻译文件中重复的源字符串
翻译中重复的语言
代码库中的合并、更新或推送失败
解析翻译文件中的错误
账单限制(请参见 账单)
代码库包含太多的外发或丢失的提交
缺少许可证
Errors when running add-on (see 附加组件)
配置错误的单语翻译。
损坏 组件配置
失效链接
未使用的屏幕截图
歧义语言代码
在组件设置中未使用的新基础
用于链接组件的重复文件掩码
The alerts are updated daily, or on related change (for example when 组件配置 is changed or when repository is updated).
警报会在每个组件页面的 警报 选项卡中列出。如果缺少该选项卡,组件会清除所有当前的检查。警报无法被忽略,但一旦根本的问题被修复,警报就会消失。
包含重复的字符串和语言的组件如下所示:

参见
构建翻译者社区
社区本地化检查清单
3.9 新版功能.
可以在每个组件的菜单中找到 社区本地化检查清单,它可以就如何让社区翻译者轻松进行本地化过程为您提供指导。

管理翻译
添加新的翻译
新的字符串当出现在基础文件中式可以用于翻译,被称为 Template for new translations`(请参见 :ref:`component)。如果您的文件格式不需要这个的文件,如在多数单语言翻译流程的情况下,可以用空白文件来开始。
在 Weblate 中,当用户要求时新的语言可以立刻加入,或者新的通知会发送给项目管理员来同一或手动添加。这可以使用 组件配置 中的:ref:component-new_lang 来实现。
注解
If you add a language file in connected remote repository, respective translation will be added to the component when Weblate updates local repository.
More info on the repository update settings can be found on the 更新仓库.
移除现有译文
Languages, components, or the projects they are in, can be removed (deleted from Weblate and remote repository if used) from the menu Manage ↓ Removal of each project, component, or language.
Initiating the Removal action shows the list of components to be removed. You have to enter the object’s slug to confirm the removal. The slug is the project’s, language’s, or component’s pathname as it can be seen in the URL.
If you want to remove just some specific strings, there are following ways:
Manually in the source file. They will be removed from the translation project as well upon Weblate’s repository update.
4.5 新版功能.
In Weblate’s UI via button Tools ↓ Remove while editing the string. This has differences between file formats, see: 管理字符串
注解
If you delete a language file in connected remote repository, respective translation will be removed from the component when Weblate updates local repository.
More info on the repository update settings can be found on the 更新仓库.
字符串变体
变体可以将几个字符串组合在一起,这样翻译人员就可以在一个地方看到字符串的所有变体。
提示
Abbreviations (shortened forms, contractions) are a good example of variants.
将基于变体的键自动化
3.11 新版功能.
可以定义正则表达式,基于 组件配置 的单语言翻译的键将字符串分组:

如果 Key 匹配表达式,那么匹配部分被删除以生成变体的根键。然后,具有相同根键的所有字符串将成为单个变体组的一部分,也包括具有与根键完全匹配的键的字符串。
后面的表格列出了一些使用示例:
用例 |
正则表达式变量 |
匹配的翻译键 |
---|---|---|
后缀识别 |
|
|
内联识别 |
|
|
手动变体
4.5 新版功能.
可以使用 variant:SOURCE
标记手动连接特定字符串。这对没有键将字符串自动分组,或者需要将键不匹配但在翻译时应一起考虑的字符串进行分组的双语翻译很有用。
The additional variant for a string can also be added using the Tools while translating (when 管理字符串 is turned on):

注解
各种字符串必须最长 768 个字符。这是由于 MySQL 数据库的兼容而导致的技术限制。
翻译时的变体
当翻译时变量在后面分组:

字符串标签
在项目配置中通过文本和颜色将组件翻译字符串分类。

复查字符串
活动报告
活动报告检查项目、组件或独立用户的翻译的更改。
一个项目或组件的活动报告可以从其控制面板上的 Info 选项卡中获取。

更多报告可以从 洞察 选项卡中获取,选择 翻译报告。
可以通过点击右上角用户菜单的 Profile,看到当前登录用户的活动。
源字符串的检查
有很多 质量检查,其中一些专注于提高源字符串的质量。很多未通过的检查都给出了建议提示,使源字符串更容易翻译。所有类型的未通过的原文检查都显示在每个组件的 Source 选项卡上。
翻译字符串的检查
错误的未通过的翻译字符串检查表明问题出在源字符串上。译者有时会更正翻译中的错误,而不是将其报告——一个典型的例子是在句子的结尾缺少一个句号。
复查所有未通过的检查可以提供有价值的反馈来改进其源字符串。为了使源字符串的复查更容易,Weblate 会自动为源语言创建一个翻译,并在那里显示源语言层次的检查:

这里一个最有趣的检查是 多项未通过的检查 ——只要给定字符串的多个翻译有一个未通过检查,就会触发它。通常情况下,这是要寻找的东西,因为这是一个译者在正常翻译时遇到问题的字符串。
具体列表是每种语言的概况:

接收源字符串反馈
翻译者可以为翻译和源字符串添加评论。每个 组件配置 都可以配置电子邮箱地址来接收这类评论(请参见 源字符串缺陷报告地址),并且使用开发者邮件列表通常是最佳方式。可以以这种方式关注翻译中出现的问题,处理它们,并迅速修复。
参见
推广翻译
Weblate 提供多种小挂件,以便你在你的网站或其它地方进行分享,推广翻译项目。Weblate 还有一个很棒的欢迎页面,可为新贡献者提供有关翻译的基本信息。此外,你可以使用 Facebook 或 Twitter 分享与翻译有关的信息。这些都可以在 分享 选项卡中找到:

所有这些徽章都提供有简单页面的链接,解释了用户如何使用 Weblate 来翻译:

翻译进程汇报
报告特性给出了给定时间内的翻译进程。提供了任何给定组件相对于时间的贡献总结。汇报工具可以在任何翻译组件、项目或面板上的 洞察 菜单中找到:

在这一页面上有几个汇报工具可用,所有工具都能够生成 HTML、reStructuredText 或 JSON格式的输出。前两个格式适于将统计数据嵌入现有的文档,而 JSON 用于进一步处理数据。
翻译者鸣谢表
生成用于记录翻译者的文档——按语言分类,并列出给定语言的所有贡献者:
* Czech
* John Doe <john@example.com> (5)
* Jane Doe <jane@example.com> (1)
* Dutch
* Jane Doe <jane@example.com> (42)
提示
括号内的数字表示给定时期的贡献数量。
贡献者统计数据
按翻译者姓名生成已翻译词与字符串的数量:
======================================== ======================================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ========================
Name Email Count total Source words total Source chars total Target words total Target chars total Count new Source words new Source chars new Target words new Target chars new Count approved Source words approved Source chars approved Target words approved Target chars approved Count edited Source words edited Source chars edited Target words edited Target chars edited
======================================== ======================================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ========================
John Done john@example.com 1 3 24 3 21 1 3 24 3 21 0 0 0 0 0 0 0 0 0 0
Jane Done jane@example.com 2 5 25 4 28 2 3 24 3 21 0 0 0 0 0 0 0 0 0 0
======================================== ======================================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ======================== ========================
如果您根据工作量来向翻译者支付报酬,这会很有用,它给出了关于翻译者工作的各种统计数据。
所有统计数据都提供三种变体:
- Total
编辑的字符串的总数。
- New
新翻译的字符串,以前没有翻译。
- Approved
在复查流程中同意的字符串数量(请参见 专门的审核者)。
- Edited
编辑的字符串,以前没有翻译。
后面是每项内容的计量:
- Count
字符串的数量。
- Edits
字符串中编辑的数量,以 Damerau–Levenshtein 距离来衡量。
- Source words
源语言字符串中单词的数量。
- Source characters
源语言字符串中字符的数量。
- Target words
翻译的字符串中单词的数量。
- Target characters
翻译的字符串中字符的数量。
为 Weblate 作贡献
有几十种方法来改进 Weblate。你可以选择一个你觉得舒服的方式,它可以是编程、图形设计、文档、赞助,或一个想法:
翻译 Weblate
Weblate 持续使用 Weblate 进行 自身的本地化翻译工作。尽你所能,使 Weblate 能以尽可能多的人类语言提供,让 Weblate 离用户更近!
If you find a possible mistake in the source string, you can mark it with a comment in the Weblate editor. This way, it can be discussed and corrected. If you’re certain, you can also click on the link in the Source string location section and submit a PR with your correction.
为 Weblate 文档作贡献
You are welcome to improve the documentation page of your choice. Do it easily by clicking the Edit on GitHub button in the top-right corner of the page.
Please respect these guidelines while writing:
Don’t remove part of the documentation if it’s valid.
Use clear and easily-understandable language. You are writing tech docs, not a poem. Not all docs readers are native speakers, be thoughtful.
Don’t be affraid to ask if you are not certain. If you have to ask about some feature while editing, don’t change its docs before you have the answer. This means: You change or ask. Don’t do both at the same time.
Verify your changes by performing described actions while following the docs.
Send PR with changes in small chunks to make it easier and quicker to review and merge.
If you want to rewrite and change the structure of a big article, do it in two steps:
Rewrite
Once the rewrite is reviewed, polished, and merged, change the structure of the paragraphs in another PR.
提示
You can translate the docs.
扩展内置语言定义
The language definitions are in the weblate-language-data repository.
You are welcome to add missing language definitions to languages.csv
,
other files are generated from that file.
Weblate 讨论
如果你有一个想法,但不确定它是否适合作为一个 issue,不用担心,你可以加入 GitHub discussions 中的社区对其进行讨论。
为 Weblate 开发提供资金
你可以在 donate page 上促进 Weblate 的发展。收集到的资金用于免费托管自由软件项目和 Weblate 的进一步发展。筹款目标和资助者的回报等选项,请查看 donate page。
资助 Weblate 的支持者
Weblate 支持者名单:
Yashiro Ccs
Cheng-Chia Tseng
Timon Reinhard
Loic Dachary
Marozed
Richard Nespithal
MyExpenses.Mobi
想出现在名单中吗?请查看 捐助 Weblate 上的选项。
开始为 Weblate 贡献代码
要理解 Weblate 源代码,请查看 Weblate 源代码、 Weblate 前端 和 Weblate 内部。
从代码库开始
想熟悉 Weblate 代码库,不如先试试对带有 good first issue 标签的那些 bug 下手。
本地运行 Weblate
开始 Weblate 开发的最舒适的方法是按照 从源码安装。它将给您一个带有可编辑的 Weblate 源代码的虚拟环境。
克隆 Weblate 源码:
git clone https://github.com/WeblateOrg/weblate.git cd weblate
创建一个虚拟环境:
virtualenv .venv .venv/bin/activate
安装 Weblate(这需要一些系统依赖项,请参见 从源码安装):
pip install -e .
安装用于开发的所有依赖项:
pip install -r requirements-dev.txt
启动一台开发服务器:
weblate runserver
取决于配置,你也许想启动 Celery workers:
./weblate/examples/celery start
要运行测试 (更多细节见 本地测试):
. scripts/test-database ./manage.py test
参见
在 Docker 中本地运行 Weblate
如果你已经安装了 Docker 和 Docker -compose,你就可以启动开发环境,只需运行:
./rundev.sh
它将新建 Docker 镜像并启动它。Weblate 运行在 <http://127.0.0.1:8080/> 上,并且你可以以 admin
为用户名, admin
为密码来登录。新的安装是空的,所以您会想要以 添加翻译项目和组件 来继续。
对此,Dockerfile
和 docker-compose.yml
位于本地的 dev-docker
目录中。
脚本还接受一些参数,要执行测试,以 test
参数来运行,然后指定任意 test
参数,例如,只在 ``weblate.machine``模块中运行测试:
./rundev.sh test --failfast weblate.machine
注解
小心在运行测试前您的 Docker 容易活动并运行。您可以通过运行 docker ps
命令来检查。
展示日志:
./rundev.sh logs
为了停止后台容器,运行:
./rundev.sh stop
运行没有任何参数的脚本将重建 Docker 容器并重启动它。
注解
这不是用于生产的合适设置,因它包括几个不安全的小技巧,但它们会使开发更容易。
使用 PyCharm 为 Weblate 编写代码
PyCharm 是 Python 的著名 IDE,这里有一些帮助你在其中建立你的 Weblate 项目的指南。
考虑到你刚刚将 GitHub 存储库复制到一个文件夹中,只需使用 PyCharm 打开它。一旦 IDE 打开,第一步要做的是指定你想要使用的解释器:

可以或者选择让 PyCharm 为您创建 virtualenv(虚拟环境),或者选择已经存在的:

一旦设置了解释程序不要忘记安装依赖:要么通过控制台(IDE的控制台默认情况下会直接使用你的 virtualenv),或者当你得到一个关于缺少依赖项的警告时通过接口。
第二步是设置正确的信息来在 PyCharm 中原生使用 Django:理念是能够立即触发 IDE 中的单元测试。 为此,你需要指定该 Django 项目的根路径及其设置路径:

要小心,Django project root`(Dejango 项目的根)是代码库的实际根目录,而不是 Weblate 子目录。关于设置,你可以使用来自代码库的 :file:`weblate/settings_test.py,你也可以创建自己的设置并在那里设置它。
最后一步是运行服务器,并将断点放置在代码中而能够调试它。这通过新建新的 Django Server 配置来完成:


提示
小心被称为 :guilabel:`No reload`的属性:如果你修改文件,它会阻止服务器被实时重新加载。这允许保留现有的调试器断点,而它们通常会在重新加载服务器时被丢弃。
引导你的开发实例
您会想要使用 import_demo
来新建演示翻译,并且使用 createadmin
来创建一名管理用户。
Weblate 源代码
Weblate 在 GitHub 上开发。欢迎您将代码复刻并开一个拉取请求。同样欢迎任何形式的补丁。
参见
查阅 Weblate 内部 来看看 Weblate 内部是什么样子的。
由设计原理来提供安全性
在为 Weblate 编写任何代码时都应该考虑到 通过设计保证安全原则 。
编程标准
代码应该符合 PEP-8 编码准则,并且应该使用 black 代码格式化程序来格式化。
为了检查代码质量,可以使用 flake8,推荐的插件列在 .pre-commit-config.yaml
中,而其配置放置在 setup.cfg
中。
将所有这些强制的最简单的方法是安装 pre-commit。Weblate 仓库为此包含了配置,来确定提交的文件是正常的。安装后(他已经包括在 requirements-lint.txt
中了)通过在 Weblate 的付款台运行 pre-commit install
来将它打开。通过这种方法,所有更改都将被自动检查。
还能够手动触发检查,来检查所有文件的运行:
pre-commit run --all
调试 Weblate
程序缺陷可以表现为应用崩溃或各种不正常行为。欢迎您搜集任何这类问题的信息,并将其提交给 issue tracker。
调试模式
打开调试模式将在网络浏览器中显示异常。对于调试 web 界面中的问题很有用,但不适用于生产环境,因为它会拖累性能,并且可能泄漏私密数据。
In a production environment, use ADMINS
to receive e-mails containing error
reports, or configure error collection using a third-party service.
Weblate 日志
Weblate 可以生成后台正在发生什么的详细日志。在默认配置中,它使用 syslog,并使日志出现在 /var/log/messages
或 /var/log/syslog
中(取决于您的 syslog 守护程序配置)。
Celery 进程(请参见 使用 Celery 的后台任务)通常也产生自己的日志。示例的系统范围的安装被记录到 /var/log/celery/
下的几个日志文件中。
Docker 容器记录它们的输出(如 Docker 世界中通常的那样),因此可以使用 docker-compose logs
来查看日志。
不处理后台任务
Celery workers 在后台完成很多事。如果像发送电子邮件或删除组件这样的事情不能正常运作,那么可能有一个相关的问题。
在那种情况下需要检查的事情:
检查 Celery 进程是否正在运行,见 使用 Celery 的后台任务
在 管理界面 中或者使用
celery_queues
检查 Celery 队列状态查看 Celery 日志寻找错误(请参见 Weblate 日志)
不接收来自 Weblate 的电子邮件
你可以使用 sendtestemail
管理命令(关于在不同环境中如何调用它的指示说明请参见 调用管理命令 )或 Tools 选项卡下的 管理界面 来验证外发电子邮件是否正常工作。
这些直接发送电子邮件,因此这验证您的SMTP配置是否正确(请参见 配置电子邮件发件箱)。然而来自 Weblate 的多数电子邮件在后台发送,并且可能也会有 Celery 相关的问题,请参阅 不处理后台任务 来调试。
分析应用的崩溃
在应用程序崩溃的情况下,尽可能多地收集有关崩溃的信息是很有用的。这可以通过使用第三方服务来实现,第三方服务可以自动收集这些信息。可以在 收集错误报告 找到如何设置的信息。
无报告的故障
很多任务写在到 Celery 进行后台处理。故障不显示在用户界面上,但出现在 Celery 的日志中。配置 收集错误报告 会帮助您更容易地注意到这样的故障。
性能问题
如果 Weblate 在某些情况下表现不佳,请收集显示问题的相关日志,以及任何可能有助于确定代码可能改进的地方的日志。
如果有些请求在没有任何提示的情况下花费了很长时间,你可能想要安装 dogslow,附加参数 收集错误报告 并在错误收集工具中获取精确和详细的回溯信息。
Weblate 内部
注解
这一章将给出 Weblate 内部的基本概况。
Weblate 从 Django 得到其多数代码架构,并基于它。
目录结构
Weblate 主仓库目录结构的速览:
docs
本文档的源码,可使用 Sphinx 来构建。
dev-docker
运行开发服务器的 Docker 代码,请参见 在 Docker 中本地运行 Weblate。
weblate
Weblate Django 应用的的源代码作为,请参见 Weblate 内部。
weblate/static
客户端文件(CSS、Javascript 和图片),请参见 Weblate 前端。
模块
Weblate 包括几个 Django 应用(一些是可选的,请参见 可选的 Weblate 模块):
accounts
用户账户、简介和通知。
addons
微调 Weblate 行为的附加组件,请参见 :ref:`addons。
api
基于 Django REST framework 的 API。
auth
认证和权限。
billing
可选的 账单 模块。
checks
翻译字符串 质量检查 模块。
fonts
字体渲染检查模块。
formats
基于 translate-toolkit 的文件格式抽象层。
gitexport
可选的 Git 导出器 模块。
lang
定义语言和复数模型的模块。
legal
可选的 法律声明 模块。
machinery
机器翻译服务的集成。
memory
内置的翻译记忆库,请参见 翻译记忆库。
screenshots
屏幕截图管理与 OCR 模块。
trans
处理翻译的主模块。
utils
各种帮助功能。
vcs
版本控制系统抽象概念。
wladmin
Django 管理界面定制化。
开发附加组件
附加组件 是在 Weblate 中自定义本地化工作流的方法。
- class weblate.addons.base.BaseAddon(storage=None)
Weblate 附加组件的基础类。
- classmethod can_install(component, user)
检查附加组件是否与给定组件兼容。
- configure(settings)
保存配置。
- daily(component)
每日触发钩子。
- classmethod get_add_form(user, component, **kwargs)
返回用于添加新附加组件的配置表单。
- get_settings_form(user, **kwargs)
返回此附加组件的配置表单。
- post_add(translation)
添加新的翻译后触发钩子。
- post_commit(component)
更改提交到仓库后触发钩子。
- post_push(component)
仓库推送到上游之后触发钩子。
- post_update(component, previous_head: str, skip_push: bool)
在仓库从上游更新之后触发钩子。
- 参数
previous_head (str) – 仓库更新前的 HEAD,在初始克隆时可以是空白的。
skip_push (bool) – 附加组件操作是否应该跳过将更改推送到上游。通常可以将这个作为``commit_and_push``或
commit_pending
传递到底层方法。
- pre_commit(translation, author)
更改被提交到仓库前触发钩子。
- pre_push(component)
在仓库推送上游之前触发钩子。
- pre_update(component)
在仓库从上游更新之前触发钩子。
- save_state()
保存附加组件状态信息。
- store_post_load(translation, store)
文件解析后触发钩子。
它接收文件格式类的事件作为参数。
这对修复该文件格式类参数有用,例如,调整文件如何存储。
- unit_pre_create(unit)
创建新的单元前触发的钩子。
这里是一个插件的例子:
#
# 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/>.
#
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 add-on should receive
events = (EVENT_PRE_COMMIT,)
# Add-on unique identifier
name = "weblate.example.example"
# Verbose name shown in the user interface
verbose = _("Example add-on")
# Detailed add-on description
description = _("This add-on does nothing it is just an example.")
# Callback to implement custom behavior
def pre_commit(self, translation, author):
return
Weblate 前端
前端当前使用 Bootstrap、jQuery 和一些第三方库来构建。
支持的浏览器
Weblate 支持所有主流浏览器和平台最新的稳定版。
不明确支持使用最新版 WebKit、Blink 或 Gecko 内核的替代浏览器,无论是直接使用还是通过平台的 web view API。但是,Weblate 应该(在大多数情况下)能在这些浏览器中正常显示和运行。
其它浏览器也能工作,但一些特性会受到限制。
依赖项管理
yarn 软件包管理工具用于更新第三方库。配置在 scripts/yarn
中,并且有个打包脚本 scripts/yarn-update
来更新库、构建它们,并复制到 weblate/static/vendor
中的正确位置上,所有的第三方前端代码都位于此目录。Webate 特定的代码应该直接放在 :file: weblate/static 或特性相关的子目录中 (例如 weblate/static/editor
)。
添加了新的第三方库,典型包括:
# Add a yarn package
yarn --cwd scripts/yarn add PACKAGE
# Edit the script to copy package to the static folder
edit scripts/yarn-update
# Run the update script
./scripts/yarn-update
# Add files to git
git add .
代码风格
Weblate 依赖于 Prettier 来进行 JavaScript 和 CSS 文件的代码格式化。
我们还使用 ESLint 来检查 JavaScript 代码。
本地化
如果在前端代码中需要任何用户可见的文本,那么应该将其本地化。在多数情况下,所有需要的是将文本打包到 gettext
函数内部,但也有更复杂的特性来使用:
document.write(gettext('this is to be translated'));
var object_count = 1 // or 0, or 2, or 3, ...
s = ngettext('literal for the singular case',
'literal for the plural case', object_count);
fmts = ngettext('There is %s object. Remaining: %s',
'There are %s objects. Remaining: %s', 11);
s = interpolate(fmts, [11, 20]);
// s is 'There are 11 objects. Remaining: 20'
图标
Weblate 目前使用 material design 图标。如果你正在找新符号,请查看 Material Design Icons 或 Material Design Resources。
此外,有 scripts/optimize-svg
来减小 SVG 的大小,因为多数图标嵌入在 HTML 中,而使路径有风格。
在 Weblate 中汇报问题
Weblate issue tracker 托管于 Github。
欢迎报告任何问题,或提出改进建议。我们准备了各种模板,可以轻松地指导你完成问题报告。
如果你在 Weblate 中发现了安全问题,请查阅下方的 安全问题 部分。
If you are not sure about your bug report or feature request, you can try Weblate 讨论.
安全问题
为了给予社区实践来响应并升级,强烈敦促您私下汇报所有的安全问题。HackerOne 用于处理安全问题,并且而可以在 HackerOne 直接汇报。一旦你在那里提交它,社区有有限但足够的时间来解决事件。
另外,可以汇报给 security@weblate.org,最后也会到 HackerOne 上。
如果因为任何原因不想使用 HackerOne,可以将报告通过电子邮件发送给 michal@cihar.com。可以选择使用这个 PGP 密钥 3CB 1DF1 EF12 CF2A C0EE 5A32 9C27 B313 42B7 511D 来加密。还以从 Keybase 得到密钥。
注解
Weblate 在很多事情上依赖于第三方组件。如果你发现一个影响这些组件的漏洞,请直接报告给相应的项目。
这些中的一些是:
Weblate 测试套件与持续集成
测试套件存在于多数当前代码,通过为任何新的功能添加测试情况来扩大覆盖范围,并确认其正常工作。
持续集成
当前的测试结果可以在 GitHub Actions 上找到,并且覆盖范围在 Codecov 上报告。
有几项工作来确认不同的方面:
单元测试
文档构建与外部链接
来自所有支持的发布版本的合并测试
代码整理
设置确认(确保生成的 dist 文件不丢失任何内容,并可以测试)
CI 的配置在 .github/workflows
目录中。它重度使用了 ci
目录中的帮助脚本。脚本还可以手动执行,但它们需要一些环境变量,多数用来定义 Django 设置要使用的文件和数据库连接。它的示例定义在 scripts/test-database
中:
# Simple way to configure test database from environment
# Database backend to use postgresql / mysql / mariadb
export CI_DATABASE=${1:-postgresql}
# Database server configuration
export CI_DB_USER=weblate
export CI_DB_PASSWORD=weblate
export CI_DB_HOST=127.0.0.1
# Django settings module to use
export DJANGO_SETTINGS_MODULE=weblate.settings_test
简单的执行看起来可以像这样:
. scripts/test-database
./ci/run-migrate
./ci/run-test
./ci/run-docs
本地测试
如果本地运行测试套件,要使用:
DJANGO_SETTINGS_MODULE=weblate.settings_test ./manage.py test
提示
您会需要使用数据库(PostgreSQL)服务器来检测。Django 默认新建另外的数据库,以 test_
前缀来运行测试,因此在您的设置配置使用 weblate
的情况下,测试会使用 test_weblate
数据库。设置的指示请参见 Weblate 的数据库设置。
weblate/settings_test.py
也用在 CI 环境中(请参见 持续集成),并且可以使用环境变量调整:
# Simple way to configure test database from environment
# Database backend to use postgresql / mysql / mariadb
export CI_DATABASE=${1:-postgresql}
# Database server configuration
export CI_DB_USER=weblate
export CI_DB_PASSWORD=weblate
export CI_DB_HOST=127.0.0.1
# Django settings module to use
export DJANGO_SETTINGS_MODULE=weblate.settings_test
运行测试前,应该收集静态文件,因为一些测试在出现时依赖于它们:
DJANGO_SETTINGS_MODULE=weblate.settings_test ./manage.py collectstatic
您也可以指定要运行的各自测试:
DJANGO_SETTINGS_MODULE=weblate.settings_test ./manage.py test weblate.gitexport
提示
测试也可以在开发者 docker 容器内执行,请参见 在 Docker 中本地运行 Weblate。
参见
运行并为 Django写测试的更多信息请参见 Django 中的测试。
数据架构
Weblate 使用 JSON Schema 来定义外部 JSON 文件的输入。
Weblate 翻译记忆库概要
类型 |
array |
||
项目 |
翻译记忆项 |
||
类型 |
对象 |
||
属性 |
|||
|
字符串类别 |
||
1 是全局的,2 是共享的,10000000+ 是项目特定的,20000000+ 使用户特定的 |
|||
类型 |
整数 |
||
例子 |
1 |
||
最小 |
0 |
||
默认 |
1 |
||
|
字符串来源 |
||
文件名或组件名 |
|||
类型 |
字符串 |
||
例子 |
test.tmx |
||
项目/组件 |
|||
默认 |
|||
|
源字符串 |
||
类型 |
字符串 |
||
例子 |
你好 |
||
最小长度 |
1 |
||
默认 |
|||
|
源语言 |
||
ISO 639-1 / ISO 639-2 / IETF BCP 47 |
|||
类型 |
字符串 |
||
例子 |
英语 |
||
模式 |
^[^ ]+$ |
||
默认 |
|||
|
目标字符串 |
||
类型 |
字符串 |
||
例子 |
Ahoj |
||
最小长度 |
1 |
||
默认 |
|||
|
目标语言 |
||
ISO 639-1 / ISO 639-2 / IETF BCP 47 |
|||
类型 |
字符串 |
||
例子 |
cs |
||
模式 |
^[^ ]+$ |
||
默认 |
|||
additionalProperties |
假 |
||
定义 |
Weblate 用户数据导出
类型 |
对象 |
|||
属性 |
||||
|
基本 |
|||
类型 |
对象 |
|||
属性 |
||||
|
用户名 |
|||
类型 |
字符串 |
|||
例子 |
管理员 |
|||
默认 |
||||
|
全名 |
|||
类型 |
字符串 |
|||
例子 |
Weblate 管理员 |
|||
默认 |
||||
|
电子邮件 |
|||
类型 |
字符串 |
|||
例子 |
||||
默认 |
||||
|
加入日期 |
|||
类型 |
字符串 |
|||
例子 |
2019-11-18T18:53:54.862Z |
|||
默认 |
||||
|
个人资料 |
|||
类型 |
对象 |
|||
属性 |
||||
|
语言 |
|||
类型 |
字符串 |
|||
例子 |
cs |
|||
模式 |
^.*$ |
|||
默认 |
||||
|
建议的字符串数量 |
|||
类型 |
整数 |
|||
例子 |
1 |
|||
默认 |
0 |
|||
|
已翻译字符串数量 |
|||
类型 |
整数 |
|||
例子 |
24 |
|||
默认 |
0 |
|||
|
已上传的截屏数 |
|||
类型 |
整数 |
|||
例子 |
1 |
|||
默认 |
0 |
|||
|
在控制面板上隐藏已完成的翻译 |
|||
类型 |
布尔值 |
|||
例子 |
假 |
|||
默认 |
真 |
|||
|
在禅模式下显示第二语音翻译 |
|||
类型 |
布尔值 |
|||
例子 |
真 |
|||
默认 |
真 |
|||
|
如果有第二翻译则隐藏原文 |
|||
类型 |
布尔值 |
|||
例子 |
假 |
|||
默认 |
真 |
|||
|
编辑器链接 |
|||
类型 |
字符串 |
|||
例子 |
||||
模式 |
^.*$ |
|||
默认 |
||||
|
翻译编辑器模式 |
|||
类型 |
整数 |
|||
例子 |
0 |
|||
默认 |
0 |
|||
|
禅编辑器模式 |
|||
类型 |
整数 |
|||
例子 |
0 |
|||
默认 |
0 |
|||
|
特殊字符 |
|||
类型 |
字符串 |
|||
例子 |
||||
模式 |
^.*$ |
|||
默认 |
||||
|
控制面板默认视图 |
|||
类型 |
整数 |
|||
例子 |
1 |
|||
默认 |
0 |
|||
|
默认组件列表 |
|||
默认 |
空 |
|||
anyOf |
类型 |
空 |
||
类型 |
整数 |
|||
|
翻译语言 |
|||
类型 |
array |
|||
默认 |
||||
项目 |
语言代码 |
|||
类型 |
字符串 |
|||
例子 |
cs |
|||
模式 |
^.*$ |
|||
默认 |
||||
|
第二语言 |
|||
类型 |
array |
|||
默认 |
||||
项目 |
语言代码 |
|||
类型 |
字符串 |
|||
例子 |
sk |
|||
模式 |
^.*$ |
|||
默认 |
||||
|
已关注项目 |
|||
类型 |
array |
|||
默认 |
||||
项目 |
项目标识串 |
|||
类型 |
字符串 |
|||
例子 |
weblate |
|||
模式 |
^.*$ |
|||
默认 |
||||
|
审计日志 |
|||
类型 |
array |
|||
默认 |
||||
项目 |
项目 |
|||
类型 |
对象 |
|||
属性 |
||||
|
IP 地址 |
|||
类型 |
字符串 |
|||
例子 |
127.0.0.1 |
|||
模式 |
^.*$ |
|||
默认 |
||||
|
用户代理 |
|||
类型 |
字符串 |
|||
例子 |
PC / Linux / Firefox 70.0 |
|||
模式 |
^.*$ |
|||
默认 |
||||
|
时间戳 |
|||
类型 |
字符串 |
|||
例子 |
2019-11-18T18:58:30.845Z |
|||
模式 |
^.*$ |
|||
默认 |
||||
|
活动 |
|||
类型 |
字符串 |
|||
例子 |
登录 |
|||
模式 |
^.*$ |
|||
默认 |
||||
定义 |
参见
发布 Weblate
发布日程
Weblate 有两个月的发布周期,版本(x.y)。
主要版本的更改指示了升级过程不能跳过这个版本——在升级到更高版本的版本 x.y 之前总是必须升级到版本 x.0。
参见
发布计划
即将发布版本的功能是通过 GitHub 里程碑收集的,可以在 <https://github.com/WeblateOrg/weblate/milestones> 上查看路线图。
发布过程
发布前要检查的事情:
由 ./scripts/list-translated-languages 来检查新翻译的语言。
由 ./scripts/prepare-release 来设置最终版本。
确保截图是最新的 make -C docs update-screenshots。
Merge any possibly pending translations wlc push; git remote update; git merge origin/weblate
执行发布:
创建一个发布 ./scripts/create-release --tag (要求请参见下面)。
手动发布步骤:
更新 Docker 镜像。
关闭 GitHub 里程碑。
一旦检测到 Docker 镜像,则添加标签并推送。
将 Helm 图表更新到新的版本。
在
.github/workflows/migrations.yml
中包含新的版本,从而在合并监测中覆盖它。Increase version in the website download links.
由 ./scripts/set-version 在仓库中增加版本。
要使用 ./scripts/create-release 脚本创建标签,需要:
带有私钥的 GnuPG,用于为发行版签名
推送访问 Weblate git 仓库(它推送标签)
配置的 hub 工具和访问,在 Weblate repo 上创建发布版本
SSH 访问 Weblate 下载服务器(网站下载内容被复制到的地方)
安全和隐私
小技巧
在 Weblate,安全维持着一个重视用户隐私的环境。
Weblate 的开发符合 Linux 基金会发起的核心基础设施计划最佳实践。
参见
Tracking dependencies for vulnerabilities
Security issues in our dependencies are monitored using Dependabot. This covers the Python and JavaScript libraries, and the latest stable release has its dependencies updated to avoid vulnerabilities.
提示
There might be vulnerabilities in third-party libraries which do not affect Weblate, so those are not addressed by releasing bugfix versions of Weblate.
Docker 容器安全
The Docker containers are regularly scanned using Anchore and Trivy security scanners.
This allows us to detect vulnerabilities early and release improvements quickly.
You can get the results of these scans at GitHub — they are stored as artifacts on our CI in the SARIF format (Static Analysis Results Interchange Format).
参见
关于 Weblate
项目目标
项目名称
“Weblate” 由单词”web”和”translate”融合而来。
项目网站
登录页面是 https://weblate.org,云托管服务在 https://hosted.weblate.org。文档在 https://docs.weblate.org。
项目标志
项目标志和其它图片可以在 https://github.com/WeblateOrg/graphics 中找到。
领导
本项目由 Michal Čihař 维护,联系方式是 michal@cihar.com。
许可协议
版权所有(C)2012 - 2021 Michal Čihař <michal@cihar.com>
本程序是自由软件:您可以在自由软件基金会发布的 GNU 通用公共许可证第三版,或(您选择的)更新版本的条款之下,将其重新发布并且/或者修改。
发布本程序希望它有用,但不作任何担保;甚至没有应用可销售性或适于特定目的的担保。更多细节请参见 GNU 通用公共许可证。
您应该与本程序一起收到 GNU 通用公共许可证的副本。如果没有的话,请参见 <https://www.gnu.org/licenses/>。
Weblate 4.10
发布于 2021 年 12 月 16 日。
新增对 DeepL Formality 参数和占位符的支持。
Bulk edit and search and replace are now available on project and language level.
为搜索和替换特性添加了筛选。
Fixed: “Perform automatic translation” privilege is no longer part of the Languages group.
“执行自动翻译”位于*管理* 和新的*自动翻译* 组中。
修复了生成带特殊字符的 XLSX 文件的问题。
Added ability to the GitHub authentication backend to check if the user belongs to a specific GitHub organization or team.
Improved feedback on invalid parameters passed to API.
新增对 API 项目范围访问令牌的支持。
Fixed string removal in some cases.
Fixed translating newly added strings.
Label automatically translated strings to ease their filtering.
Weblate 4.9.1
发布于 2021 年 11 月 19 日。
修复了更改模板后单语言文件的上传问题。
改进了对标记中空白字符的处理。
下载 API 新增对过滤的支持。
修复了添加新翻译时的统计数据显示。
Mitigate issues with GitHub SSH key change.
Weblate 4.9
发布于 2021 年 11 月 10 日。
提供历史记录中事件的更多详情。
改进了历史的呈现。
改进了翻译页面的性能。
新增支持限制翻译文件下载。
The
safe-html
can now understand Markdown when used withmd-text
.The
max-length
tag now ignores XML markup when used withxml-text
.Fixed dimensions of rendered texts in 最大翻译大小.
Lowered app store title length to 30 to assist with upcoming Google policy changes.
新增支持通过
SSH_EXTRA_ARGS
自定义 SSH 调用。新增了对 ICU MessagFormat 的检查。
改进了机器翻译后端中的错误状况处理。
突出显示字符串中不常见的空白字符。
新增编辑时停留在已翻译字符串的选项。
新增支持通过
BORG_EXTRA_ARGS
定制 Borg 调用。修复了为单语言翻译生成 MO 文件。
新增 API 端点,支持以 ZIP 文件打包下载所有组件翻译。
增加了对 Python 3.10 的支持。
新增支持从管理界面重新发送电子邮件邀请。
Weblate 4.8.1
发布于 2021 年 09 月 10 日。
修复了 Django 管理界面中的用户删除。
在文档中更详细地说明附加组件的参数。
修复了术语表的 JavaScript 错误。
在一致性检查中增加匹配数量的限制。
改进机器翻译中的占位符处理。
修复了使用 API 创建附加组件的问题。
Added
PRIVACY_URL
setting to add privacy policy link to the footer.Hide member e-mail addresses from project admins.
Improved gettext PO merging in case of conflicts.
改进了术语表高亮。
Improved
safe-html
flag behavior with XML checks.修复了链接组件的提交消息。
Weblate 4.8
发布于 2021 年 08 月 21 日。
新增对 Apple stringsdict 格式的支持。
The exact search operator is now case-sensitive with PostgreSQL.
修正了某些情况下保存术语解释的问题。
文档改进。
性能改进。
改进了 squash 附加组件与 Gerrit 的兼容性。
修正了向单语术语表组件添加字符串的问题。
改进了处理变体的性能。
Fixed squash add-on sometimes skipping parsing upstream changes.
保留下载文件扩展名。
增加了对 Fluent 格式的支持。
支持使用制表符缩进 JSON 格式。
Weblate 4.7.2
发布于 2021 年 07 月 15 日。
支持在项目上配置更多的语言别名。
修复了 API 中搜索字符串验证问题。
修正了域名变更后的 Git 导出器 URL 问题。
修正了 Windows RC 文件的清理附加组件。
修复了更新 XLIFF 时可能的崩溃。
Weblate 4.7.1
发布于 2017 年 07 月 30 日。
改进了向语汇中添加术语的弹窗。
新增对 LibreTranslate 机器翻译服务的支持。
增加了创建新项目的速率限制。
改进了文件更新的性能。
Weblate 4.7
发布于 2021 年 06 月17 日。
改进了配置健康性的检查。
添加了对 gettext PO 中所用的
object-pascal-format
的支持,见 Object Pascal 格式。Renamed Nearby keys to Similar keys to better describe the purpose.
新增了对 mi18n 语言文件 的支持。
改进了 SAML 验证集成。
Fixed Gerrit integration to better handle corner cases.
Weblate 现在需要 Django 3.2。
修正了电子邮件身份验证被禁用时邀请用户的问题。
改进了语言定义。
增加了阻止用户参与项目的功能。
修复了术语表语言的自动创建。
扩展了关于附加组件的文档。
改善了带链接仓库的组件的性能。
增加了对免费 DeepL API 的支持。
用户管理不再需要 Django 管理界面。
Weblate 4.6.2
发布于 2021 年 05 月 08 日。
修复了在项目之间移动共享组件后的崩溃。
修复了将新字符串添加到空属性文件的问题。
修复了 RTL 语言中的副本图标对齐。
扩展了信息选项卡上的字符串统计信息。
修复了 Git 中忽略的翻译文件的处理。
改进了度量性能。
修复了保存术语表可能发生的错误。
修复了具有不同复数规则的语言的一致性检查行为。
Weblate 4.6.1
发布于 2021 年 05 月 02 日。
删除了过时的垃圾邮件防护代码。
提高了原文复数检查的准确性。
更新 Docker 中的用户界面语言列表。
改进了创建拉取请求的错误信息。
修复了在 Pagure 上创建拉取请求的问题。
修复了触发自动安装的附加组件的问题。
修复了升级时可能出现的缓存问题。
修复了使用上传将新单元添加到单语翻译中的问题。
Weblate 4.6
发布于 2020 年 04 月 19 日。
The auto_translate management command has now a parameter for specifying translation mode.
新增了对 文本文件 的支持。
增加了所有对象的趋势和指标。
新增支持从辅助语言直接复制文本。
新增浏览变化时日期过滤。
改进了活动图表。
现在可以配置联系人表单电子邮件的发件人。
改进了组件新建 API 中的参数验证。
The rate limiting no longer applies to superusers.
改进了自动翻译附加组件的性能和可靠性。
现在可以在 Docker 容器中自定义速率限制。
API for creating components now automatically uses Weblate internal URLs.
简化了列出字符串时的状态提示。
密码散列现在默认使用Argon2。
简化了显示翻译状态的进度条。
Renamed 添加缺少的语言 to clarify the purpose.
修复可了保存字符串状态到 XLIFF 的问题。
添加了在全部语言范围内的搜索。
Initial support for 横向扩展 the Docker deployment.
Weblate 4.5.3
发布于 2020 年 04 月 01 日。
修复了指标收集的问题。
修复了添加字符串时可能的崩溃。
改进的搜索查询示例。
修正了替换上传时可能会丢失新添加的字符串的问题。
Weblate 4.5.2
发布于 2021 年 03 月 26 日。
可配置的自动翻译时间表。
添加了 Lua 格式检查。
Ignore format strings in the 连续重复的单词 check.
允许从翻译页面上传截图。
向存储库维护添加了强制文件同步。
修复了代码较长的语言的自动建议。
改进了添加新字符串时的性能。
修复了几处质量检查中的错误。
几处性能改进。
添加了与 发现 Weblate 的集成。
修复了对只读字符串的检查行为。
Weblate 4.5.1
发布于 2021 年 03 月 05 日。
修正了在某些特殊情况下编辑术语表标记的问题。
Extend metrics usage to improve performance of several pages.
以 TMX 文件存储正确的源语言。
使用 API 更好地处理单语言 PO 的上传。
改进了术语表组件的警报行为。
改进了 Markdown 链接检查。
在面包屑导航中指示术语表和源语言。
对大型项目中的组件清单进行分页。
改进翻译、部件或项目移除的性能。
改进了批量编辑的性能。
Fixed preserving “Needs editing” and “Approved” states for ODF files.
改进了自定义翻译文件下载的界面
Weblate 4.5
发布于 2021 年 02 月 19 日。
添加了对 gettext PO 中所用的
lua-format
的支持。新增支持在项目间共享一个组件。
用多种格式标记修复了多个未命名变量检查行为。
去掉了项目的邮件列表字段,为翻译者提供通用说明。
添加了用于生成假语言环境的附加组件。
添加了对 TermBase eXchange 文件的支持。
增加了对使用标记手动定义字符串变体的支持。
改进了一致性检查的性能。
改进了长字符串翻译记忆库的性能。
增加了在解释中搜索的支持。
Strings can now be added and removed in bilingual formats as well.
扩展亚马逊机器翻译支持的语言。
自动启用Java 属性的 Java MessageFormat 检查。
增加了一种新的将新字符串添加到翻译的上传方法。
添加了浏览翻译的简单界面。
Glossaries are now stored as regular components.
Dropped specific API for glossaries as component API is used now.
添加了用于切换某些标记的简化界面。
增加了对术语表中不可翻译或禁止的术语的支持。
支持在术语表中定义专有名词。
Moved text direction toggle to get more space for the visual keyboard.
添加了自动关注用户贡献的项目的选项。
添加了检查翻译是否与术语表匹配的功能。
添加了对自定义导航文本颜色的支持。
Weblate 4.4.2
发布于 2021 年 1 月 14 日。
修复了一个发布的 MO 文件的崩溃问题。
Weblate 4.4.1
发布于 2021 年 1 月 13 日。
修复了还原复数更改。
修复了展示项目设置帮助。
改进了用户管理。
改进了单语言 PO 文件中上下文的处理。
修复了 HTML、ODF、IDML 和 Windows RC 格式的清理附加组件的行为。
修复了从 CSV 文件解析位置的错误。
下载文件时使用内容压缩。
改进了从 ZIP 文件导入的用户体验。
改进了对上传文件格式的检测。
避免在 Pagure 上重复拉取请求。
改进了显示 ghost 翻译时的性能。
重新实现翻译编辑器,使用原生浏览器文本区。
修复了清理附加组件破坏添加新字符串功能的问题。
添加了附加组件 API。
Weblate 4.4
发布于 2020 年 12 月 15 日。
改进了新建组件时的验证。
Weblate 现在需要Django 3.1。
支持在管理界面中自定义外观。
修复了批量编辑时只读状态的处理。
改进了 CodeMirror 集成。
添加了从翻译文件中删除空白字符串的附加组件。
CodeMirror编辑器现在用于翻译。
为 XML、HTML、Markdown 和 reStructuredText 在翻译编辑器中语法高亮。
在翻译编辑器中突出显示可放置位置。
改进了对非标准语言代码的支持。
添加了使用歧义语言代码时的警报。
添加新的翻译时,用户会看到过滤后的语言列表。
扩展了更改历史的搜索能力。
改进了账单详情页面和自由软件项目托管流程。
扩展了翻译统计 API。
改进了翻译时“其他翻译”选项卡。
添加了任务 API。
改进了文件上传的性能。
改进了用户定义的特殊字符的显示。
改进了自动翻译的性能。
几处用户界面的小改进。
改进了 ZIP 文件下载的命名。
添加了获取未关注项目通知的选项。
Weblate 4.3.2
发布于 2020 年 11 月 4 日。
修复了某个组件文件掩码的崩溃。
提高了连续重复的单词检查的准确性。
新增了对 Pagure 拉取请求的支持。
改进了注册失败的错误消息。
撤销了以 Markdown 格式渲染开发者注释。
简化了默认分支非 “master” 的Git仓库的安装设置。
新建的内部仓库现在使用主干作为默认分支。
降低了翻译重构文本时未更改译文的误报率。
修复了一些情况下的 Codemirror 显示问题。
将模板组重命名为“原文”,以澄清其含义。
修复了路径较长代码仓库的 GitLab 拉取请求。
Weblate 4.3.1
发布于 2020 年 10 月 21 日。
改进了自动翻译性能。
修复了身份已验证用户的会话过期问题。
新增了对隐藏版本信息的支持。
改进了钩子与 Bitbucket 服务器的兼容性。
改进了翻译记忆库更新的性能。
减少了内存的使用。
改进了矩阵视图的性能。
增加了将一名用户从一个项目移除前的确认功能。
Weblate 4.3
发布于 2020 年 10 月 15 日。
包括了 API 中的用户统计数据。
修复了分页的页面上订购的组件。
定义了术语表的源语言。
重写了对 GitHub 和 GitLab 拉取请求的支持。
修复了移除建议后的统计数据计数。
扩展了公开的用户个人资料。
修复了强制检查的配置。
改进了内建备份的文档。
将源语言属性从项目移动到组件。
添加了 Vue I18n 格式化检查。
通用占位符的检查现在支持了正则表达式。
改进了矩阵模式的外观。
机器翻译现在被称为自动建议。
增加了与多个GitLab或GitHub实例交互的支持。
扩展了 API 以覆盖项目更新、单元更新与删除,以及术语表。
单元 API 现在能正常处理多个字符串。
组件的新建现在能够处理上传的 ZIP 文件或文档。
巩固了 API 相应状态代码。
在贡献者协议中支持 Markdown。
改进了源字符串追踪。
改进了 JSON、YAML 和 CSV 格式兼容性。
增加了对删除字符串的支持。
改进了文件下载的性能。
改进了仓库管理视图。
为 Android 自动启动 java 格式。
增加了对本地化截图的支持。
新增了对 Python 3.9 的支持。
修复了某些条件下翻译 HTML 文件。
Weblate 4.2.2
发布于 2020 年 09 月 02 日。
修复了 JSON 格式源字符串的匹配。
修复了一些验证配置的登录重定向。
修复了使用组同步的LDAP身份验证。
修复了与报告自动翻译进度相关的崩溃。
修复了启用额外信息时的 Git 压缩提交问题。
修复了使用 API 创建本地版本控制系统(VCS)组件。
Weblate 4.2.1
发布于 2020 年 08 月 21 日。
修复了在安装资源中一些区域设置存储复数。
修复了一些 XLIFF 文件清理附加组件的崩溃。
允许在 Docker 镜像中设置本地化 CDN。
Weblate 4.2
发布于 2020 年 8 月 18 日。
改进了用户页面并添加了用户列表。
去掉了从 3.x 版本迁移的支持,从 4.0 或 4.1 迁移。
添加了几种单语言格式的导出。
改进了活动图表。
可以配置字符串附近显示的数字。
增加了对锁定遇到存储库错误的组件的支持。
简化了主导航栏(用图标替换按钮)。
改进了 Google Translate 集成中的语言代码处理。
Git 变形附加组件可以生成
Co-authored-by:
额外信息。改进了查询搜索解析。
改进了格式字符串检查的用户反馈。
改进了批量更改状态的性能。
添加了项目或组件重命名后重定向的兼容性。
为字符串的统一、组件的锁定和许可的更改添加了通知。
为 ModernMT 添加了支持。
允许在文件上传时避免覆盖已同意的翻译。
去掉了一些对兼容 URL 重定向的支持。
添加了对ECMAScript模板文本的检查。
添加了关注组件的选项。
去掉了来自 JSON 单元密钥的前导的点。
删除了翻译记忆库单独的 Celery 队列。
允许使用同一种语言同时翻译所有组件。
允许配置
Content-Security-Policy
HTTP 标头。在项目层为语言别名添加支持。
帮助 HTML 或 JavaScript 本地化的新附加组件,请参见 JavaScript 本地化 CDN。
Weblate 域现在在设置中配置,请参见
SITE_DOMAIN
。增加了对按照组件和项目进行搜索的支持。
Weblate 4.1.1
发布于 2020 年 06 月19 日。
修复了 Docker 中更改自动修复或附加组件配置。
修复了在“关于”页面中可能的崩溃。
改进了字节编译的区域设置文件的安装。
修复了向术语表添加单词。
修复了机器翻译的键盘快捷键。
删除了一些设置中导致丢失日志事件的调试输出。
修复了在项目列表中所定指示。
修复了一些设置中列出 GPG 密钥。
为需要使用的 DeepL API 版本添加了选项。
为作为 SAML 服务提供商添加了支持,请参见 SAML 身份验证。
Weblate 4.1
发布于 2020 年 06 月 15 日。
支持了使用包含国家地区代码创建新翻译。
增加了对用截图搜索源字符串的支持。
扩展了统计数据洞察中可用的信息。
改进了在“翻译”页面上的搜索编辑。
改进了并发仓库更新的处理。
在项目新建表单中包括了源语言。
包括了信用的更改计数。
修复了一些情况下的 UI 语言选择。
允许注册关闭时的白名单注册方法。
改进了术语表中相关术语的查找。
改进了翻译记忆库匹配。
将相同的机器翻译结果分组。
为编辑翻译页面的屏幕截图添加了直接链接。
改进了删除确认对话。
在 ZIP 下载中包括了模板。
为声明中的标记和通知配置添加了支持。
扩展了检查列表的细节。
新增了对以下文件格式的支持:Laravel PHP 字符串, HTML 文件, OpenDocument Format, IDML Format, Windows RC 文件, INI 翻译, Inno Setup INI 翻译, GWT 属性, go-i18n JSON 文件, ARB 文件。
统一使用已忽略作为已忽略检查的状态。
添加了对配置要启用的默认附加组件的支持。
修复了编辑器忽略检查的键盘快捷键。
改进了带有占位符的字符串的机器翻译。
显示了用户语言的幽灵翻译,使之易于启动。
改进了语言代码解析。
显示了列表中的第一个用户语言的翻译。
重命名来塑造为更一般的名称变体。
为擦除翻译记忆库重新引入了支持。
修复了忽略原文检查的选项。
为配置不同分支来解析更改添加了支持。
API 现在在 HTTP 标头重报告速率限制状态。
对 Google Translate V3 API(高级版)添加了支持。
添加了对组件层访问限制的能力。
为翻译标记中的空白字符和其它特殊字符添加了支持,请参见 使用标记定制行为。
总是显示受到的文本检查,如果启动的话。
API 现在支持对更改的筛选。
为项目之间分享术语表添加了支持。
Weblate 4.0.4
发布于 2020 年 05 月 7 日。
修复了测试套件在一些 Python 3.8 环境下的执行。
文档中笔误的修复。
修复了一些情况下使用 API 新建组件的问题。
修复了破坏移动端导航栏的 JavaScript 错误。
修复了显示一些检查时的崩溃。
修复了屏幕截图列表。
修复了每月摘要通知。
修复了使用翻译中不存在的单元的中间翻译行为。
Weblate 4.0.3
发布于 2020 年 05 月 2 日。
修复了报告中可能的崩溃。
在评论中提及用户时用户名现在不区分大小写。
修复了非超级用户的 PostgreSQL 迁移。
修复了新建组件时更改仓库 URL。
修复了上游仓库丢失时的崩溃。
Weblate 4.0.2
发布于 2020 年 04 月 27 日。
改进了翻译统计数据的性能。
改进了更改标签的性能。
改进了批量编辑的性能。
改进了翻译记忆库的性能。
修复了组件删除时可能的崩溃。
修复了一些极端情况下显示翻译更改的问题。
改进了 celery 队列过长的警告。
改进了一致性检查中的误报。
修复了更改链接组件仓库时的死锁。
包括了更改列表和 CSV 与 报告中的编辑距离。
避免了对加拿大法语进行符号间隔检查时的误报。
修复了用占位符导出 XLIFF。
修复了零宽度检查的误报。
改进了配置错误的报告。
修复了双语原文上传的问题。
为 DeepL 机器翻译自动检测支持的语言。
修复了一些极端情况下的进度条显示问题。
修复了非翻译字符串出发的一些检查。
Weblate 4.0.1
发布于 2020 年 04 月 16 日。
修复了来自 Pypi 的软件包安装。
Weblate 4.0
发布于 2020 年 04 月 16 日。
Weblate 现在需要 Python 3.6 或更新版本。
添加了组件警报的管理概览。
添加了仓库浏览器链接失效的组件警报。
改进了登陆和注册页面。
项目访问控制与工作流程配置集成在项目设置中。
为 i18next 插值和嵌套添加了检查和高亮标记。
为百分号占位符添加检查和高亮标记。
显示未通过检查的建议。
在历史中记录源字符串更改。
将 Microsoft Translator 升级为版本 3 的 API。
重新应用翻译记忆库后端。
为在 搜索 中查找几个
is:
添加了支持。允许 未更改的翻译 避免内部黑名单。
改进了从单语言 po 文件中提取注释。
将白板信息改名为公告。
修复了注册邮件偶尔出现的问题。
改进了 LINGUAS 更新附加组件来处理更多的语法变量。
修复了编辑单语言 XLIFF 源文件。
为 搜索 中的准确匹配添加了支持。
扩展了 API 覆盖屏幕截图、用户、用户组、组件列表,并扩展了新建项目。
新增了对双语翻译原文上传的支持。
为开发者的中间语言添加支持。
为源字符串复查添加支持。
扩展了平台范围的翻译记忆库的下载选项。
Weblate 3.x 系列
Weblate 3.11.3
发布于 2020 年 03 月 11 日。
修复了以某种优先性来搜索字段。
修复了最近添加的字符串的预设查询。
修复了搜索返回重复的匹配。
修复 Gmail 中提供的通知。
修复了从历史中还原更改。
添加了到摘要通知中的事件的链接。
修复了账户删除确认的电子邮件。
添加了对 Docker 容器中 Slack 身份认证的支持。
避免发送未订阅语言的通知。
在性能概况中包括了 Celery 队列。
修复了附加组件的文档链接。
减少了未更改的译文检查的误报。
提升了 bleach 依赖项以解决 CVE-2020-6802。
修复了在历史中列出项目层的更改。
修复了一些极端情况下的统计数据被验证为非法。
修复了搜索某个字符串状态。
改进了格式字符串检查行为丢失百分比的问题。
修复了使用第三方提供商的身份验证。
Weblate 3.11.2
发布于 2020 年 02 月 22 日。
修复了提出建议的问题。
修复了一些字符串被错误地报告为没有单词的问题。
Weblate 3.11.1
发布于 2020 年 02 月20 日。
记录 Celery 设置更改。
改进了新建组件时文件名的验证。
修复了一些依赖项的最低版本。
修复了以某个 Django 版本添加群组。
修复了手动推送到上游仓库。
改进了术语表匹配。
Weblate 3.11
发布于 2020 年 02 月 17 日。
允许通过 API 新建组件的过程中使用版本控制系统(VCS)推送 URL。
宽度检查现在以渲染来显示图片。
修复了通知电子邮件中的链接。
改进了纯文本电子邮件的外观。
显示了忽略的检查并且允许使它们再次激活。
在单语言翻译上显示附件的键。
添加了对分组字符串整形的支持。
在系统检查时推荐更新为新的 Weblate 版本。
对重复的语言警报提供了更详细的分析。
在项目页面上显示更详细的许可证信息。
如果需要的话自动非浅复制本地复件。
修复了需要动作的字符串下载。
新增警报,将对两次使用相同的文件掩码发出警告。
改进了 XML 代码块提取。
SINGLE_PROJECT
现在可以强制重定向来选择项目。添加了解决评论的选项。
添加了批量编辑标记功能。
为 字符串标签 添加了支持。
添加了批量编辑附加组件。
为 强制检查 添加了选项。
增加了确认链接的默认验证。
改进了 Matomo 集成。
修复了 曾被翻译过 来正确低处理源字符串更改。
扩展了通过
AUTO_UPDATE
的自动更新配置。LINGUAS 附加组件现在在 Weblate 中完全同步翻译。
Weblate 3.10.3
发布于 2020 年 01 月 18 日。
支持 translate-toolkit 2.5.0。
Weblate 3.10.2
发布于 2020 年 01 月 18 日。
为项目添加了锁定指示。
修复了导致某些浏览器闪烁的 CSS 错误。
修复了以非英语地区设置在系统中搜索。
改进了对 Github 和 Bitbucket 钩子的仓库。
修复了一些 Python 2.7 安装中的数据的迁移。
允许 Git 钱克隆的配置。
改进了后台通知处理。
修复了在浏览器中导航返回时中断的表单提交。
配置 YAML 格式化的新附加组件。
修复了单复数形式语言中没有进行相同的复数检查。
修复了相同字段的 regex 搜索。
Weblate 3.10.1
发布于 2020 年 01 月 09 日。
扩展了新建翻译 API。
修复了数据迁移的几个极端情况。
与 Django 3.0 兼容。
改进了数据清理性能。
为定制的 security.txt 添加了支持。
改进了更改日志的面包屑(breadcrubs)。
改进了面板上的翻译列表。
改进了 Webhooks 的 HTTP 响应。
在 Docker 容器中添加了 GitLab 和并请求。
Weblate 3.10
发布于 2019 年 12 月 20 日。
改进了应用用户界面。
添加了双空格检查。
修复了新建新的语言。
避免了向删除的电子邮箱发送审计日志。
新增支持只读字符串。
在评论中增加了对 Markdown 的支持。
允许在项目信息中放置翻译指示文本。
为第二语言添加了复制到剪贴板。
改进了对 Mercurial 的支持。
改进了 Git 仓库获取性能。
添加了搜索字符串时间的查找。
为所有翻译显示源语言。
显示字符串附近的上下文。
为仓库操作的通知添加了支持。
改进了翻译列表。
扩展了搜索能力。
为标记为编辑的自动翻译字符串添加了支持。
避免对链接组件警报发送重复通知。
改进了默认的合并请求消息。
更好地指示了在禅模式下的字符串状态。
为 Yandex 翻译中的更多语言添加了支持。
改进了通知电子邮件的外观。
提供了翻译许可的选择。
Weblate 3.9.1
发布于 2019 年 10 月 28 日。
从备份中删除了一些不需要的文件。
修复了报告的潜在崩溃。
修复了数据库交叉迁移故障。
对强制推送 Git 仓库添加了支持。
降低了注册令牌非法的风险。
修复了账户删除点击率的限制。
添加了基于优先性的搜索。
修复了向 JSON 文件添加字符串可能的崩溃。
安全 HTML 检查于修复现在接受源字符串标记。
避免向邀请的和删除的用户发送通知。
修复了在 Docker 容器中 Celery 的到 redis 的 SSL 连接。
Weblate 3.9
发布于 2019 年 10 月 15 日。
在下载的文件中包括了 Weblate 元数据。
改进了未通过检查的 UI。
在格式检查中指示缺少的字符串。
将法语标点间隔检查分开。
为修复一些质量检查错误添加了支持。
添加了分开的权限来新建新的项目。
扩展了字符计数的统计数据。
改进了对 Java 风格语言代码的支持。
为新的占位符提供的通用检查。
为 WebExtension JSON 占位符添加了支持。
为纯 XML 格式添加了支持。
扩展了 API 的项目、组件和翻译的删除与新建。
为 Gitea 和 Gitee webhooks 添加了支持。
添加了新的定制的基于正则表达式的检查。
允许配置对共享翻译记忆库的贡献。
添加了更多翻译文件的 ZIP 下载。
使 XLIFF 标准兼容最大宽度和字体的解析。
为传输 web 应用的安全 HTML 标记添加了新的检查并进行了修复。
对不支持的配置添加了组件警报。
添加了自动翻译附加组件来引导翻译。
扩展了自动翻译来添加建议。
在概览上显示附加组件参数。
现在通过当代的 Sengtry SDK 而不是 Raven 支持 Sentry。
更改了示例设置,更好地适配生产环境。
添加了使用 BorgBackup 的自动备份。
分离了 RESX 清理附加组件,来避免不想要的文件更新。
添加了高级搜索功能。
允许用户下载他们自己的报告。
添加了本地化向导来配置组件。
增加了对 GitLab Merge Request 的支持。
改进了仓库状态的显示。
在后台执行自动翻译。
Weblate 3.8
发布于 2019 年 08 月 15 日。
为简化创建相似的组件提供了支持。
为从基于 XML 的文件格式分析翻译标记添加了支持。
将意外记入 Celery 日志。
提高存储库范围附加组件的性能。
改进了通知电子邮件的外观。
修复了密码重置行为。
改进了多数翻译页面的性能。
修复了 Weblate 未知的语言列表。
支持将附加组件克隆到发现的组件。
为用上传来替换文件内容添加了支持。
为翻译非基于版本控制系统(VCS)的内容添加了支持。
添加了 OpenGraph 小挂件图片,以便在社交网络使用。
为动画屏幕截图添加了支持。
改进了单语言 XLIFF 文件的处理。
避免为单个事件发送多个通知。
为筛选更改添加了支持。
扩展了报告的预定义周期。
为 Azure Repos 添加了 webhook 支持。
待定建议或未翻译字符串的新的选择使用通知。
添加了通知电子邮件的一键退订。
修复了已翻译检查的误报。
管理员的新管理界面。
字符串优先性现在可以使用标记来指定。
添加了语言管理视图。
添加了 Qt 库和 Ruby 格式字符串的检查。
添加了配置来更好地符合单一项目安装。
在单语言翻译中通过源字符串更改中的新字符串。
添加带有搜索功能的另外的翻译记忆库视图。
Weblate 3.7.1
发布于 2019 年 06 月 28 日。
文档更新。
修复了一些要求限制。
更新了语言数据库。
本地化更新。
各种用户界面调整。
改进了对不支持但发现的翻译文件的处理。
更详细地报告丢失文件格式要求。
Weblate 3.7
发布于 2019 年 06 月 21 日。
添加了用于通知的另外的 Celery 队列。
对于 API 浏览使用了与应用一致的外观。
在报告中包括了同意的统计数据。
当更新翻译组件时的报告过程。
允许终止运行后台组件的更新。
为文件名操作扩展了模板语言。
对于编辑器链接和仓库浏览器 URL 使用模板。
当编辑翻译时指示最大长度和当前字符计数。
改进了未更改翻译检查中的缩写处理。
为新贡献者设计的全新登录页面。
支持配置 msgmerge 附加组件。
当发送通知时延迟打开 SMTP 连接。
改进了错误日志。
允许 MO 生成附加组件中的自定义位置。
添加了清理陈旧建议或评论的附加组件。
添加了选项来启动禅编辑器的水平模式。
提高了许多被链接组件的导入性能。
修复了一些情况下的示例安装。
改进了变更中警报的呈现方式。
添加了新水平统计数据小挂件。
改进了复数的格式字符串检查。
添加了字体管理工具。
提供文本尺寸的新检查。
为字幕格式添加了支持。
包括了语言的全部完成的统计数据。
添加了在项目或全体范围内的报告。
改进了显示翻译状态时的用户界面。
新的 Weblate 标志和配色方案。
位图徽章的新外观。
Weblate 3.6.1
发布于 2019 年 04 月 26 日。
改进了单语言 XLIFF 文件的处理。
修复了一些极端情况下的摘要通知。
修复了附加组件脚本错误警报的问题。
修复了为单语言 PO 文件生成 MO 文件。
修复了未安装检查的显示。
指示项目列表中管理的项目。
允许更新而从丢失的版本控制系统(VCS)仓库恢复。
Weblate 3.6
发布于 2019 年 04 月 20 日。
为下载用户数据添加了支持。
附加组件在安装时会被自动触发。
改进了解决合并冲突的指示。
清理附加组件现在与应用商店元数据翻译兼容。
当添加新语言时可配置的语言代码语法。
警告 Python 2 的使用计划于 2020 年 04 月终止支持。
为视觉键盘从源字符串中提取特定字符。
扩展了贡献者统计数据,来反映原文和目标相关计数。
管理员和一致性附加组件现在可以添加翻译,即使对用户禁用。
修复了禁止
Language-Team
标头操作切换的描述。通知评论中提及的用户。
从组件设置中删除了文件格式自动检测。
修复了为单语言 PO 文件生成 MO 文件。
添加了摘要通知。
为组件通知静音添加了支持。
添加了新警报、白板消息或组件的通知。
现在可以配置管理项目的通知。
改进了三字母语言代码的处理。
Weblate 3.5.1
发布于 2019 年 03 月 10 日。
修复了 Celery systemd 单元例子。
修复了带有登录的 HTTP 仓库的通知。
修复了单语言翻译中编辑源字符串的竞态条件。
在日志中包括附加组件执行失败的输出。
改进了添加新语言选择的验证。
在组件设置中允许编辑文件格式。
更新安装指示为首选 Python 3。
装入翻译时的性能与一致性改进。
使 Microsoft Terminology 服务与当前的 Zeep 发布版本兼容。
本地化更新。
Weblate 3.5
发布于 2019 年 03 月 03 日。
改进了内建翻译记忆库的性能。
添加了管理全体翻译记忆库的界面。
改进了对不良组件状态的警报。
添加了管理白板消息的用户界面。
现在可以配置附加组件提交消息。
减少更新上游仓库时的提交数量。
修复了在项目之间移动组件时可能的元数据丢失。
改进了禅模式的导航。
添加了几个新的质量检查(相关的标记和 URL )。
新增了对应用商店元数据文件的支持。
为切换 GitHub 或 Gerrit 集成添加了支持。
为卡什达字母添加了检查。
添加选项来根据作者压缩提交。
改进了对 XLSX 文件格式的支持。
与 Tesseract 4.0 兼容。
账单附加组件现在在未支付账单 45 天后删除项目。
Weblate 3.4
发布于 2019 年 01 月 22 日。
为 XLIFF 占位符添加了支持。
Celery 现在可以使用多个项目队列。
为项目与组件的重命名和移动添加了支持。
在报告中包括字符计数。
添加了带有翻译文件自动检测的翻译组件添加向导。
可定制的 Git 合并提交消息。
在导航栏中添加了组件警报的视觉指示。
改进了装入翻译文件的性能。
在推送前压缩提交的新附加组件。
改进了翻译更改的显示。
将默认的合并方式改为变基,并使其可配置。
更好地处理语言代码中的私用子标签。
改进了全文索引更新的性能。
扩展了文件上传 API 来支持更多的参数。
Weblate 3.3
发布于 2018 年 11 月 30 日。
为组件和项目删除添加了支持。
改进了一些单语言翻译的性能。
添加了翻译组件警报,以突出显示翻译中的问题。
XLIFF 字符串 resname 可用时将其暴露为上下文。
为 XLIFF 状态添加支持。
为 DATA_DIR 中的非可写入文件添加检查。
改进了更改的 CSV 导出。
Weblate 3.2.2
发布于 2018 年 10 月 20 日。
删除了不再需要的 Babel 依赖项。
更新了语言定义。
改进了附加组件、LDAP 和 Celery 的文档。
修复了启动新的 dos-eol 和 auto-java-messageformat 标记。
修复了从 PyPI 软件包运行 setup.py 测试。
改进了复数处理。
修复了一些极端情况下失败的翻译上传 API。
修复了手动更改情况下更新 Git 配置。
Weblate 3.2.1
发布于 2018 年 10 月 18 日。
Python 2.7 的 backports.csv 的文档依赖项。
修复根下运行测试。
改进了 gitexport 模块中的错误处理。
修复了报告新添加语言的过程。
正确地向 Sentry 报告 Celery worker 错误。
修复了用 Qt linguist 新建新的翻译。
修复了偶发的全文索引更新失败。
改进了新建新组件时的验证。
为清理旧的建议添加了支持。
Weblate 3.2
发布于 2018 年 10 月 06 日。
为自动化的附加组件安装添加 install_addon 管理命令。
允许更细粒度的速率限制设置。
为 Excel 文件的导出和导入添加了支持。
改进了多组件发现附加组件情况下的组件清理。
重写了 Microsoft Terminology 机器翻译后端。
Weblate 现在使用 Celery 来卸载一些处理。
改进了搜索功能,并添加了正则表达式搜索。
为有道智云机器翻译添加了支持。
为百度 API 机器翻译添加了支持。
集成了使用 Celery 的维护和清理任务。
改进了装入翻译的性能几乎 25%。
删除了对上传时合并标头的支持。
删除了对客户提交消息的支持。
可配置的编辑模式(禅模式/全模式)。
为向 Sentry 报告错误添加了支持。
为每天自动更新仓库添加了支持。
为用户新建项目和组件添加了支持。
内建的翻译记忆库现在自动存储完成的翻译。
用户和项目现在可以导入他们现有的翻译记忆库。
更好地管理屏幕截图的相关字符串。
为检查 Java MessageFormat 添加了支持。
已解决问题的详细列表请参见 GitHub 上的 3.2 里程碑。
Weblate 3.1.1
发布于 2018 年 07 月 27 日。
修复了一些设置中失败的测试套件。
Weblate 3.1
发布于 2018 年 07 月 27 日。
不再支持从早于 3.0.1 的更旧版本的升级。
允许覆盖从设置中默认提交的消息。
改进 webhooks 与自主环境的兼容性。
添加了对 Amazon Translate 的支持。
与 Django 2.1 兼容。
Django system 系统检查现在用于诊断安装问题。
删除了对即将关闭的 libravatar 服务的支持。
将未改变的翻译标记为需要编辑的新附加组件。
为翻译时跳到特定位置添加支持。
现在可以定制下载翻译。
改进了翻译记忆库中匹配字符串相似度的计算。
支持了使用 GnuPG 为 Git 提交签名。
Weblate 3.0.1
发布于 2018 年 06 月 10 日。
修复了自 2.20 依赖可能的合并问题。
本地化更新。
删除了过时的钩子的例子。
改进了缓存文档。
改进了管理文档的显示。
改进了长语言名称的处理。
Weblate 3.0
发布于 2018 年 06 月 01 日。
重写了访问控制。
导致移动或重命名模块的一些代码清理。
自动组件发现的新附加组件。
import_project 管理命令现在有一些略微不同的参数。
为 Windows RC 文件添加了基本支持。
新的附加组件,将贡献者姓名存储在 PO 文件标头中。
删除了每组件钩子脚本,转而使用附加组件替代。
为收集贡献者协议添加支持。
现在在历史中跟踪访问控制更改。
新附加组件,以确保项目中的所有组件都有相同的翻译。
在提交消息模板中支持更多变量。
为提供另外的文本上下文添加支持。
Weblate 2.x 系列
Weblate 2.20
发布于 2018 年 04 月 04 日。
改进了 subversion 仓库克隆的速度。
更改了仓库锁定来使用第三方库。
为下载只需要动作的字符串添加了支持。
支持了同时搜索多种语言。
新附加组件来配置 gettext 输出换行。
新附加组件来配置 JSON 格式化。
为使用 RFC 6750 兼容的 Bearer 认证添加了 API 中认证的支持。
未使用机器翻译服务自动翻译添加了支持。
为白板消息中的 HTML 标记添加了支持。
为大量更改字符串的状态添加了支持。
现在至少需要 2.3.0 版本的Translate-toolkit,较老的版本不再支持。
添加了内建翻译记忆库。
为面板添加了组件概况和每个组件列表概况的页面。
为 DeepL 机器翻译服务添加了支持。
机器翻译结果现在缓存在 Weblate 内。
增加了对已提交更改重新排序的支持。
Weblate 2.19.1
发布于 2018 年 02 月 20 日。
修复了从 2.18 升级的合并问题。
改进了文件上传 API 验证。
Weblate 2.19
发布于 2018 年 02 月 15 日。
修复了跨一些文件格式的导入。
在审查日志中显示用户友好的浏览器信息。
为文件添加了 TMX 导出程序。
装入翻译文件的各种性能改进。
添加了选项在 Weblate 中禁止访问管理,有利于 Django。
改进了大字符串的术语表查询速度。
与 django_auth_ldap 1.3.0 兼容。
配置错误现在被存储并被持久地报告。
在空白字符自动修复中尊重忽略标记。
改进了一些 Subversion 设置的兼容性。
改进了内建机器翻译服务。
对 SAP Translation Hub 服务添加了支持。
为 Microsoft Terminology 服务添加了支持。
删除了对通知电子邮件中的广告的支持。
改进了语言层次的翻译过程报告。
改进了不同复数形式的支持。
添加了对不使用 stdlayout 的 Subversion 仓库的支持。
添加了自定义翻译工作流程的附加组件。
Weblate 2.18
发布于 2017 年 12 月 15 日。
扩展了贡献者的统计数据。
改进了特殊字符可视键盘的配置。
为 DTD 文件格式添加了支持。
更改了键盘快捷键,以减少与浏览器/系统快捷键的冲突。
改进了对 XLIFF 文件中的同意标记的支持。
添加了对 gettext PO 文件中不换行的长字符串的支持。
添加了按钮为当前翻译复制永久链接。
去掉了对 Django 1.10 的支持,而添加了对 Django 2.0 的支持。
删除了当翻译时对翻译的锁定。
对于为单语言翻译添加新的字符串添加了支持。
对专门复核人员的翻译流程添加了支持。
Weblate 2.17.1
发布于 2017 年 10 月 13 日。
修复了在一些特定情况下运行测试套件的问题。
区域设置更新。
Weblate 2.17
发布于 2017 年 10 月 13 日。
现在 Weblate 默认进行 Git 浅克隆。
改进了更新大的翻译文件时的性能。
为阻挡注册的某个电子邮件地址添加了支持。
用户现在可以删除自己的评论。
为搜索和替换特性添加了预览步骤。
搜索和上传表单时客户端一侧设置的持久性。
扩展了搜索能力。
每个项目的更细粒度的 ACL 配置。
BASE_DIR 的默认值已经更改。
添加了两步账户删除,来防止意外删除。
现在可以编辑项目访问控制设置。
添加了使用 Akismet 建议的可选垃圾邮件保护。
Weblate 2.16
发布于 2017 年 08 月 11 日。
各种性能改进。
为嵌套 JSON 格式添加了支持。
为 WebExtension JSON 格式添加了支持。
修复了 git 导出认证。
改进了某些情况下的 CSV 导入。
改进了其它翻译小挂件的外观。
对于表单中的文本长度现在强制进行最大长度检测。
每个组件进行 commit_pending 时间配置。
各种用户界面清理。
修复了组件/项目/网站范围的翻译搜索。
Weblate 2.15
发布于 2017 年 06 月 30 日。
在其它翻译中显示了更多相关的翻译。
添加了选项来查看当前字符串到其它语言的翻译。
对立陶宛语默认使用 4 种复数形式。
修复了不同格式单语言文件的上传。
改进了认证失败的错误消息。
当从术语表删除单词时保持页面状态。
添加了直接链接来编辑第二语言翻译。
添加了 Perl 格式质量检查。
为了拒绝再次使用的密码添加了支持。
为编辑 RTL 语言扩展了工具条。
Weblate 2.14.1
发布于 2017 年 05 月 24 日。
修复了将搜索结果分页时可能的错误。
修复了一些极端情况下从较老的版本合并的问题。
修复了关注和取消关注项目时可能出现的 CSRF。
密码重置不再认证用户。
修复了忘记密码是可能的略过 CAPTCHA。
Weblate 2.14
发布于 2017 年 05 月 17 日。
使用 AJAX 添加术语表条目。
退出登录现在使用 POST 来避免 CSRF。
API 密钥令牌重置现在使用 POST 来避免 CSRF。
Weblate 默认设置 Content-Security-Policy。
验证本地编辑器 URL 来避免 self-XSS。
现在默认相对于一般缺陷来验证密码。
向用户通知他们账户的重要活动,如密码变更。
CSV 导出现在会避免可能的公式。
安全上的各种小改进。
现在限制了认证尝试的次数。
建议的内容存储在历史中。
在审计日志中存储重要的账户活动。
当删除账户或添加新的团体时,询问密码确认。
当做出建议时显示时间。
新的质量检查:分号结尾。
确保搜索链接可以被分享。
在 API 中包括了源字符串信息和屏幕截图。
允许通过 API 上传覆盖翻译。
Weblate 2.13.1
发布于 2017 年 04 月 12 日。
修复了个人资料中管理的项目的列表。
修复了在一些许可丢失的情况下的合并问题。
修复了翻译下载中当前文件的列表。
当用户没有特权而尝试访问项目时返回 HTTP 404。
Weblate 2.13
发布于 2017 年 04 月 12 日。
修复了翻译模板的质量检查。
添加了在丢失翻译时触发的质量检查。
添加选项来查看用户待定的建议。
添加选项来自动建立组件列表。
未经身份验证用户可以配置默认控制面板。
添加选项来浏览 25 个随机字符串用于复查。
历史现在指示字符串的更改。
添加新的翻译时更好的错误报告。
在项目中添加了每种语言的搜索。
Group(群组)ACLs 现在可以限制为某个权限。
现在使用 Group ACL 来实现每项目的 ACL。
添加了更精细颗粒的特权控制。
各种小的 UI 改进。
Weblate 2.12
发布于 2017 年 03 月 03 日。
改进了群组的管理界面。
为 Yandex Translate API 添加了支持。
改进了网站范围的搜索速度。
添加了项目和组件范围的搜索。
添加了项目和组件范围的搜索与替换。
改进了不一致翻译的渲染。
支持了在本地编辑器中打开源文件。
为配置带有特殊字符的虚拟键盘添加了支持。
改进了带有 OCR 支持的屏幕截图管理来匹配源字符串。
默认提交消息现在包括翻译信息和 URL。
为 Joomla 翻译格式添加了支持。
改进了重要的跨文件格式的可靠性。
Weblate 2.11
发布于 2017 年 01 月 31 日。
在语言页面包括了具体语言信息。
Mercurial 后端改进。
添加了选项来制定翻译组件优先性。
更一致地使用 Group ACLs,即使具有较少使用的许可。
为钩子脚本添加了 WL_BRANCH 变量。
改进了开发者文档。
在 Git 导出器附加组件中与各种 Git 版本有更好地兼容。
包括每个项目的和组件的统计数据。
添加语言代码映射,来更好地支持 Microsoft Translate API。
将全文清理移动为后台工作,使去除翻译更快速。
修复了具有单复数形式的语言的复数原文显示。
改进了 import_project 中的错误处理。
各种性能改进。
Weblate 2.10.1
发布于 2017年 01 月20 日。
不泄露密码重置表单上存在账户(CVE-2017-5537)。
Weblate 2.10
发布于 2016 年 12 月 15 日。
添加质量检查,来检查是否复数被翻译出来。
对带有验证的仓库修复了 GitHub 钩子。
添加了可选的 Git 导出模块。
支持 Microsoft Cognitive Services Translator API。
简化了项目和组件用户界面。
添加了自动修复来删除控制字符。
为项目添加了每种语言的概况。
为 CSV 导出添加了支持。
为统计数据添加了 CSV 下载。
增加了矩阵视图,以快速概述所有翻译。
为更改和字符串添加了基本 API。
为 Apertium APy 服务器添加了支持,用于机器翻译。
Weblate 2.9
发布于 2016 年 11 月 04 日。
扩展了 createadmin 管理命令的参数。
扩展了 import_json,而能够处理现有组件。
新增了对 YAML 文件的支持。
项目所有者现在可以配置翻译组件和项目细节。
使用”Watched”(已关注)而不是”Subscribed”(已订阅)项目。
可以从项目页面直接关注项目。
添加多语言状态小挂件。
如果不显示原文,则将第二语言高亮。
将建议删除记录在历史中。
改进个人资料中语言选择的用户体验。
修复了显示组件的白板信息。
保存后保持偏好选项卡被选中。
更突出地显示源字符串注释。
从 Git 仓库自动安装 Gettext PO 合并驱动。
添加搜索和替换特性。
支持上传翻译的可视化上下文(截图)。
Weblate 2.8
发布于 2016 年 08 月 31 日。
文档改进。
翻译。
更新了附带的 JavaScript 库。
添加了 list_translators 管理命令。
不再支持 Django 1.8。
修复了与 Django 1.10 的兼容性。
添加了 Subversion 支持。
将 XML 有效性检查与 XML 不匹配的标签检查分开。
修复了 API 来接受 HIDE_REPO_CREDENTIALS 设置。
在禅模式中显示原文变更。
现在也可以在禅模式下也可以使用 Alt+PageUp/PageDown/Home/End 了。
添加提示来显示更改的准确时间。
添加选项从翻译页面中选择筛选程序和搜索。
添加了翻译删除的 UI。
改进了插入代码块时的行为。
修复了禅模式的自动锁定问题。
Weblate 2.7
发布于 2016 年 07 月 10 日。
去除了 Google web translation 机器翻译。
改进了 添加翻译时的提交消息。
修复了希伯来语的 Google Translate API。
与 Mercurial 3.8 的兼容性。
添加了 import_json 管理命令。
纠正了列出翻译的顺序。
显示全部建议文本,而只是差别。
扩展 API(具体的仓库状态、统计数据、……)。
测试套件不再需要网络范文来测试仓库。
Weblate 2.6
发布于 2016 年 04 月 28 日。
修复了语言筛选程序的验证组件。
改进了对 XLIFF 文件的支持。
修复了非英语原文的机器翻译。
添加了 REST API。
Django 1.10 的兼容性。
为白板纤细添加了分类。
Weblate 2.5
发布于 2016 年 03 月 10 日。
修复了项目所有者的自动翻译。
改进了提交和推送操作的性能。
新的管理命令,从命令行添加建议。
为文件上传时的合并注释添加了支持。
为 C printf 格式的一些 GNU 后缀添加了支持。
文档改进。
为生成翻译者信用添加了支持。
为生成贡献者统计数据添加了支持。
网站范围的搜索可以只在一种语言中搜索。
改进了亚美尼亚语的质量检查。
为开始没有现有翻译的翻译组件添加支持。
支持在 Qt TS 中添加新的翻译。
改进了翻译 PHP 文件的支持。
质量检查的性能提高。
修复了全站搜索未通过的检查的问题。
新增了指定源语言的选项。
改进了对 XLIFF 文件的支持。
扩展了 import_project 选项的列表。
改进了白板消息的目标。
支持跨项目的自动翻译。
优化全文搜索索引。
为自动翻译添加了管理命令。
添加了代码块高亮。
为代码块、检查和机器翻译添加了键盘快捷键。
改进了翻译锁定。
为 AngularJS 插值添加了质量检查。
添加了广泛的基于群组的 ACLs。
阐明了需要编辑的字符串的术语(以前被称为 fuzzy,即模糊)。
明确需要动作的字符串和不需要翻译的字符串的术语。
支持 Python 3。
去掉了对 Django 1.7 的支持。
去掉了用于新建 gettext PO 文件的 msginit 依赖项。
添加了可配置的面板视图。
改进了解析错误的通知。
在 import_project 中增加了导入名称重复的组件的选项。
改进了翻译 PHP 文件的支持。
添加了字典的 XLIFF 导出。
为所有翻译添加了 XLIFF 和 gettext PO 导出。
文档改进。
为可配置的自动群组指定添加了支持。
改进了新翻译的添加。
Weblate 2.4
发布于 2015 年 09 月 20 日。
改进了对 PHP 文件的支持。
为匿名用户添加 ACL 的能力。
改进了 import_project 命令的配置。
添加了 历史的 CSV 转储。
避免复制/粘贴空白字符的错误。
为 Bitbucket webhooks 添加了支持。
在翻译上传时对模糊字符串更严格的控制。
几个 URLs 已经更改,可能必须要更新您的书签。
钩子脚本以 VCS root 作为当前目录执行。
钩子脚本以描述当前组件的环境变量来执行。
添加了管理命令来优化全文索引。
为滚动条上报告错误添加了支持。
项目现在可以有多个所有者。
项目所有者可以管理自己。
为 gettext PO 中使用的
javascript-format
添加了支持。在 XLIFF 中添加新翻译的支持。
改进了文件格式自动检测。
扩展了键盘快捷键。
改进了多种语言的字典匹配。
改进了多数页面的布局。
支持在翻译时将单词添加入字典。
为筛选语言由 Weblate 管理 添加了支持。
为翻译并导入 CSV 文件添加了支持。
重写了静态文件的处理。
第三放服务的直接登录/注册链接,如果是唯一一个的话。
账户删除时提交待定的更改。
添加管理命令来更改网站名称。
添加选项来配置默认提交者。
在添加新翻译后添加钩子。
添加选项来指定多个文件来添加提交。
Weblate 2.3
发布于 2015 年 05 月 22 日。
去掉对 Django 1.6 和 South migrations 的支持。
支持使用 Java 属性文件时添加新翻译。
允许接受建议而不编辑。
改进了对 Google OAuth 2.0 的支持。
添加了对 Microsoft .resx 文件的支持。
微调了默认的 robots.txt 文件而不允许翻译特别缓慢地进行。
简化了接受建议的工作流程。
添加了总是接收重要通知的项目所有者。
允许禁止编辑单语言模板。
更具体的仓库状态视图。
更改翻译时编辑模板的直接链接。
允许为项目所有者添加更多的权限。
允许在禅模式下显示第二语言。
支持隐藏源字符串而有利于第二语言。
Weblate 2.2
发布于 2015 年 02 月 19 日。
性能改进。
对位置和评论字段进行全文搜索。
基于 SVG/JavaScript 的新活动图表。
支持 Django 1.8。
支持删除评论。
添加自己的 SVG 徽章。
新增了对 Google Analytics(分析)的支持。
改进了翻译文件名的处理。
为单语言 JSON 翻译添加了支持。
在历史中记录组件锁定。
支持为单语言翻译编辑源(模板)语言。
为 Gerrti 添加了基本支持。
Weblate 2.1
发布于 2014 年 12 月 05 日。
为 Mercurial 仓库添加了支持。
由 Awesome 替换了Glyphicon 字体。
添加了社交验证服务的图标。
更一致的按钮颜色和图标。
文档改进。
各种缺陷修复。
对于小屏幕自动隐藏翻译列表中的列。
更改了文件系统路径的配置。
改进了 SSH 密钥处理与存储。
改进了仓库锁定。
每个源字符串可定制的质量检查。
允许从面板上隐藏完成的翻译。
Weblate 2.0
发布于 2014 年 11 月 06 日。
使用 Bootsctrap 的新的仓库 UI。
重写了 VCS 后端。
文档改进。
为网站范围的消息添加了白板。
可配置的字符串优先性。
为 JSON 文件格式添加了支持。
修复了某些情况下生成 mo 文件。
为 GitLab 通知添加了支持。
添加了支持来禁止翻译建议。
Django 1.7 支持。
ACL 项目现在具有用户管理。
扩展了搜索可能性。
为翻译者给出复数的更多提示。
修复了 Git 仓库锁定。
与旧的 Git 版本的兼容性。
改进了 ACL 支持。
新增了每种语言的引号和其他特殊字符按钮。
支持导出统计数据作为 JSONP。
Weblate 1.x 系列
Weblate 1.9
发布于 2014 年 05 月 06 日。
Django 1.6 兼容性。
不再维护与 Django 1.4 的兼容性。
用于锁定/解锁翻译的管理命令。
改进了对 Qt TS 文件的支持。
用户现在可以删除他们的账户。
头像可以被禁止。
合并了名字和姓氏属性。
头像现在可以取回并缓存在服务器一侧。
为 shields.io 徽章添加了支持。
Weblate 1.8
发布于 2013 年 11 月 07 日。
关于升级的指示,请查看手册。
更好地列出了项目概况。
优化了分享选项的外观。
对匿名用户特权的更多控制。
支持使用第三方服务登录,请查阅手册了解详情。
用户可以通过电子邮件地址而不是用户名登录。
文档改进。
改进了源字符串复查。
跨所有字符串的搜索。
更好地跟踪源字符串。
注册的 Captcha 保护。
Weblate 1.7
发布于 2013 年 10 月 07 日。
关于升级的指示,请查看手册。
支持检查 Python brace 格式字符串。
每个组件的质量检查定制。
具体的每个翻译的统计数据。
更改了将建议、检查与注释连接到字符串的方式。
用户现在可以添加文本来提交消息。
支持新语言请求的订阅。
支持添加新的翻译。
现在使用 Pillow 而不是 Pango+ Cairo 来生成小挂件和图表。
添加状态徽章小挂件。
去掉了无效的文本方向检查。
字典中的更改现在在历史中记入日志。
翻译视图的性能改进。
Weblate 1.6
发布于 2013 年 07 月 25 日。
注册时更好的错误处理。
更改的浏览。
修复了机器翻译建议的排序。
改进了对 MyMemory 机器翻译的支持。
为 Amagam 机器翻译添加了支持。
频繁使用的页面上的各种优化。
在搜索结果中将搜索到的短语高亮。
支持存储消息时的自动修复。
跟踪翻译历史和选项来还原。
为 Google Translate API 添加了翻译。
为管理 SSH 主机密钥添加了支持。
各种表单验证改进。
各种质量检查改进。
导入的性能改进。
为建议投票添加了支持。
清理管理员界面。
Weblate 1.5
发布于 2013 年 04 月 16 日。
关于升级的指示,请查看手册。
添加了公共用户页面。
更好地命名复数形式。
为术语表的 TBX 导出添加了支持。
为 Bitbucket 通知添加了支持。
现在可以为每个翻译、语言或用户提供活动图表。
扩展了 import_project admin 命令的选项。
与 Django 1.5 兼容。
现在使用 libravatar 显示头像。
为 pretty print JSON 导出添加了可能性。
各种性能改进。
在项目或语言的进度条中也会显示未通过的检查或模糊字符串了。
为客户预提交投资与提交另外的文件添加了支持。
重写了搜索实现更好的性能与用户体验。
机器翻译的新界面。
添加了对单语言 po 文件的支持。
扩展了缓存的元数据的量,来改进各种搜索的速度。
现在也显示单词计数。
Weblate 1.4
发布于 2013 年 01 月 23 日。
修复了删除字符串时检查/评论的删除问题。
添加了选项来禁止自动传播翻译。
添加了选项为合并失败而订阅。
正确地导入需要客户 ttkit 导入程序的项目。
添加了网站地图允许爬虫更容易地访问。
在通知电子邮件或 feed 中提供到字符串的直接链接。
对管理员界面的各种改进。
在管理员界面中为生产设置提供提示。
添加了每种语言的小挂件和参与页面。
改进了翻译锁定处理。
显示小挂件更多款式对应的代码片段。
在进度条中显示未通过的检查或模糊字符串。
用于将提交信息格式化的更多选项。
修复了机器翻译服务的错误处理。
改进了自动翻译锁定行为。
支持显示不同于之前的源字符串的更改。
为字串搜索添加了支持。
各种质量检查改进。
支持每个项目的 ACL。
基本代码由单元测试来覆盖。
Weblate 1.3
发布于 2012 年 11 月 16 日。
与 PostgreSQL 数据库后端兼容。
将上游 git 仓库中删除的语言也删除。
改进了质量检查处理。
添加了新的检查(BB 代码、XML 标记和新的行)。
支持可选的变基而不是合并。
重新定位 Weblate 的可能性(例如在 /weblate 路径下运行)。
支持在自动检测失败的情况下手动选择文件类型。
更好地支持 Android 资源。
支持从 web 界面生成 SSH 密钥。
更多的可视化数据导出。
新的按钮来输入一些特殊字符。
支持导出字典。
支持锁定整个 Weblate 安装。
检查源字符串,并支持源字符串复查。
支持翻译和源字符串的用户评论。
更好地更改日志跟踪。
现在更改可以使用 RSS 监测。
改进了对 RTL 语言的支持。
Weblate 1.2
发布于 2012 年 08 月 14 日。
Weblate 现在为数据库迁移使用 South,如果升级的话请检查升级的指示。
修复了连接 git repos 的小问题。
用于吸引人们使用 Weblate 参与翻译的全新介绍页面。
添加了可用于推广翻译项目的小挂件。
添加了选项将仓库重置为原始状态(对于有特权的用户)。
现在可以为翻译锁定项目和组件。
禁止一些翻译的可能性。
添加新翻译的可配置选项。
每个项目的 git 提交的配置。
简单的防垃圾邮件保护。
主页面更好的布局。
支持每次提交时自动推送更改。
支持译者电子邮件通知。
在配置编辑器中只列出使用的语言。
改进了当导入项目时对未知语言的处理。
支持翻译者锁定翻译。
可选地维护 po 文件中的
Language-Team
标头。在 about 页面中包括一些统计数据。
支持(并且需要)django-registration 0.8。
缓存带有未通过检查的字符串的计数。
在设置中检查要求。
文档改进。
Weblate 1.1
发布于 2012 年 07 月 04 日。
改进了几个翻译。
新建组件时更好的验证。
为在组件之间分享 git 仓库添加了支持。
不必每次尝试都提交来拉取远程 repo。
为卸载索引添加了支持。
Weblate 1.0
发布于 2012 年 05 月 10 日。
改进了添加/存储组件时的验证。
实验性支持 Android 组件文件(需要打补丁的 ttkit)。
来自钩子的更新在后台运行。
改进了安装指示。
改进了字典中的导航。
Weblate 0.x 系列
Weblate 0.9
发布于 2012 年 04 月 18 日。
修复了未知语言的导入。
改进了附近消息的列表。
改进了几项检查。
文档更新。
增加了另外几种语言的定义。
各种代码清理。
文档改进。
更改了文件布局。
将帮助脚本更新为 Django 1.4。
改进了翻译时的导航。
更好地处理 po 文件的重命名。
新建组件时更好的验证。
将完全设置集成到 syncdb 中。
在所有翻译页面中增加了近期变更列表。
检查未翻译的字符串,忽略格式字符串只检查消息。
Weblate 0.8
发布于 2012 年 04 月 03 日。
用 Whoosh 代替自己的全文搜索。
对检查的各种修复和改进。
新的命令更新检查。
很多翻译更新。
添加了字典,来存储最常用的术语。
为仓库状态的概况添加了 /admin/report/。
机器翻译服务不会再阻碍页面加载了。
管理界面现在也包含有用的行为来更新数据。
记录用户所做更改的日志。
推至提交给 Git 的能力,来产生来自单一用户的更少的提交。
可以浏览未通过的检查。
使用已经翻译的字符串来自动翻译。
新的显示使用的版本的页面。
Django 1.4 的兼容性。
从 web 界面将更改推送给远程 repo 的能力。
添加了对其他人完成的翻译进行复查。
Weblate 0.7
发布于 2012 年 02 月 16 日。
对 GitHub 通知的直接支持。
添加了对清洁孤立的检查与翻译的支持。
翻译时显示附近的字符串。
翻译时显示相似的字符串。
改进了字符串的搜索。
Weblate 0.6
发布于 2012 年 02 月 14 日。
添加了对翻译的消息的各种检查。
可调整的访问控制。
改进了对新一行翻译的处理。
添加了客户端一侧表单的排序。
升级时请查看升级说明。
Weblate 0.5
发布于 2012 年 02 月 12 日。
- 通过使用后面的服务对机器翻译的支持:
Apertium
微软的 Translator
MyMemory
几个新的翻译。
改进了上游更改的合并。
更好地处理并发的 git 拉取与翻译。
传播那些同样用于模糊更改的工作。
传播那些同样用于文件上传的工作。
修复了使用 FastCGI(也可能是其它)时的文件下载。
Weblate 0.4
发布于 2012 年 02 月 08 日。
将使用向导添加到文档中。
修复了不需要 CSRF 保护的 API 钩子。
Weblate 0.3
发布于 2012 年 02 月 08 日。
优化复数翻译原文的显示。
Sphinx 格式的新文档。
翻译时显示第二语言。
改进了错误页面,来给出现有项目的列表。
新的每种语言的统计数据。
Weblate 0.2
发布于 2012 年 02 月 07 日。
改进了几种形式的验证。
在个人资料升级时警告用户。
记住 URL 用于登录。
输入复数形式时对文本区域的命名。
自动扩大翻译区域。
Weblate 0.1
发布于 2012 年 02 月 06 日。
初始发布。
评论
Three types of comments can be posted: for translations, source strings, or to report source string bugs when this functionality is turned on using 启用原文复查. Choose the one suitable to topic you want to discuss. Source string comments are in any event good for providing feedback on the original string, for example that it should be rephrased or to ask questions about it.
你可以在所有评论中使用 Markdown 语法,并用
@mention
提及其他用户。参见
接收源字符串反馈, 源字符串复查, 启用原文复查