配置¶
所有的设置存储在 settings.py
中,(如 Django 通常那样)。
注解
在更改这些设置的任何一部分后,需要重新启动 Weblate —— WSGI 和 Celery 两个过程。
在它作为 mod_wsgi 运行的情况下,需要重新启动 Apache ,来重新载入配置。
参见
还要请查看 Django’s documentation 中关于配置 Django 自身的参数。
AUTH_LOCK_ATTEMPTS¶
2.14 新版功能.
在rate限制应用前,授权尝试失败的最多次数。
当前,这应用在后面的位置:
登录。删除账户密码,防止用户不请求新的密码而登录。
密码重置。防止发出新的电子邮件,避免向用户发出太多密码重置尝试的垃圾邮件。
默认为 10 。
参见
AUTO_UPDATE¶
3.2 新版功能.
在 3.11 版更改: 改变原来的开关选项,来区别接受哪个字符串。
以每天的频率更新所有仓库。
提示
在不使用 通知钩子 来自动更新 Weblate 仓库的情况下有用。
注解
除了字符串选项还存在开关选项,用于向后兼容。
选项有:
"none"
不进行每日更新。
"remote"
也是False
只进行远程更新。
"full"
也是True
更新远程,并合并工作副本。
注解
这需要 Background tasks using 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/'
参见
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',
)
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 类提供完全合规的路径。
调整检查列表,来包括与您相关的那些检查。
所有内建的 质量检查 默认都打开,可以从那里更改设置。它们在 Sample configuration 中被默认注释掉,从而使用默认值。然后每个新的 Weblate 版本执行新的检查。
可以关闭所有检查:
CHECK_LIST = ()
可以只打开一部分检查:
CHECK_LIST = (
'weblate.checks.chars.BeginNewlineCheck',
'weblate.checks.chars.EndNewlineCheck',
'weblate.checks.chars.MaxLengthCheck',
)
注解
更改这些设置只影响新更改的翻译,现存的检查仍然存储在数据库中。为了将更改同样应用到存储的翻译中,运行 updatechecks
。
DATA_DIR¶
Weblate 文件夹将所有数据存储其中。它包含到 VCS 仓库的链接,全文本索引和外部工具的各种文件。
后面的子目录通常存在:
home
Home 目录用于调用脚本。
ssh
SSH 密钥和配置。
static
静态 Django 文件的默认位置,由
STATIC_ROOT
指定。media
Django 媒体文件的默认位置,由
MEDIA_ROOT
指定。vcs
版本控制仓库。
backups
每日备份数据,细节请参考 下载的数据用于备份 。
注解
这个目录必须由 Weblate 写入。运行作为 uWSGI 意味着 www-data
用户应该对它具有写入权限。
实现这个的最简单方式是使用户作为目录的所有者:
sudo chown www-data:www-data -R $DATA_DIR
默认到 $BASE_DIR/data
。
DEFAULT_ACCESS_CONTROL¶
3.3 新版功能.
新项目的默认访问控制设置:
0
Public
1
Protected
100
Private
200
Custom
如果手动管理 ACL 则使用 Custom ,这意味着不依赖于 Weblate 内部管理。
DEFAULT_ADD_MESSAGE, DEFAULT_ADDON_MESSAGE, DEFAULT_COMMIT_MESSAGE, DEFAULT_DELETE_MESSAGE, DEFAULT_MERGE_MESSAGE¶
不同操作的默认执行信息,细节请查阅 Component configuration 。
DEFAULT_ADDONS¶
安装在每个创建的组件上的默认附加组件。
注解
此设置只影响新创建的组件。
例:
DEFAULT_ADDONS = {
# Addon with no parameters
"weblate.flags.target_edit": {},
# Addon with parameters
"weblate.autotranslate.autotranslate": {
"mode": "suggest",
"filter_type": "todo",
"auto_source": "mt",
"component": "",
"engines": ["weblate-translation-memory"],
"threshold": "80",
}
}
DEFAULT_PULL_MESSAGE¶
Pull Request 的标题,默认为 'Update from Weblate'
。
ENABLE_HTTPS¶
将链接作为 HTTPS 还是 HTTP 发送给 Weblate。这个设置影响发送电子邮件,并产生绝对 URL。
提示
在默认配置中,这还用于与 HTTPS 相关的几个 Django 设置。
ENABLE_SHARING¶
打开/关闭 :guilabel: Share 菜单,使用户能够将翻译过程分享到社交网络上。
GOOGLE_ANALYTICS_ID¶
谷歌分析 ID ,开启使用谷歌分析对 Weblate 的监控。
HIDE_REPO_CREDENTIALS¶
隐藏仓库证明避免出现在 web 网站界面中。在仓库 URL 带有用户名和密码的情况下, Weblate 会在相关信息显示给用户时将其隐藏起来。
例如除了 https://user:password@git.example.com/repo.git
会只显示 https://git.example.com/repo.git
。它也试图以相似的方式清除 VCS 错误信息。
注解
默认这是打开的。
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¶
用于显示的许可以外的选项。
注解
这个过滤器使用了短许可名称。
例如:
LICENSE_FILTER = {"AGPL-3.0", "GPL-3.0-or-later"}
LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH¶
给定翻译的长度是否应被限制。限制为源字符串的长度 * 10 个字符。
提示
将其设置为 False
来允许更长的翻译,而不管源字符串的长度。
注解
默认为 True
。
LOCALIZE_CDN_URL and 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 login
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_URL¶
您想要跟踪的 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 密钥一样的另外的配置,细节请查阅其文件 ref: machine 。
MT_SERVICES = (
'weblate.machinery.apertium.ApertiumAPYTranslation',
'weblate.machinery.deepl.DeepLTranslation',
'weblate.machinery.glosbe.GlosbeTranslation',
'weblate.machinery.google.GoogleTranslation',
'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_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_VERSION¶
4.1.1 新版功能.
DeepL 服务使用的 API 版本。版本限制了使用范围:
- v1
意味着计算机辅助翻译工具,并且在基于用户的订阅时使用。
- v2
意味着 API 应用,并且订阅是基于使用的。
此前 Weblate 被 DeepL 分类为计算机辅助翻译工具,因此应该使用 v1 API ,但现在应该使用 v2 API 。这样默认为 v2 ,您可以在现有计算机辅助翻译工具订阅,并想要 Weblate 使用它的情况下,将其更改为 v1 。
MT_GOOGLE_CREDENTIALS¶
API v3 JSON credentials file obtained in the Google cloud console. Please provide a full OS path. Credentials are per service-account affiliated with certain project. Please check https://cloud.google.com/docs/authentication/getting-started for more details.
MT_GOOGLE_PROJECT¶
API v3 Google cloud project id with activated translation service and billing activated. Please check https://cloud.google.com/appengine/docs/standard/nodejs/building-app/creating-project for more details
MT_GOOGLE_LOCATION¶
API v3 Google Cloud Application Engine may be specific to a location.
Change accordingly if the default global
fallback does not work for you.
Please check https://cloud.google.com/appengine/docs/locations for more details
MT_MICROSOFT_BASE_URL¶
Region base URL domain as defined in the “Base URLs” section.
Azure Global 的默认值为 api.cognitive.microsofttranslator.com
。
对于 Azure China ,请使用 api.translator.azure.cn
。
MT_MICROSOFT_COGNITIVE_KEY¶
Microsoft Cognitive Services Translator API 客户端密匙。
MT_MICROSOFT_REGION¶
Region prefix as defined in “Multi service subscription”.
MT_MICROSOFT_ENDPOINT_URL¶
Region endpoint URL domain for access token as defined in the “Authenticating with an access token” section.
Azure Global 的默认值为 api.cognitive.microsoft.com
。
For Azure China, please use your endpoint from the Azure Portal.
MT_MYMEMORY_EMAIL¶
MyMemory identification e-mail address. It permits 1000 requests per day.
MT_MYMEMORY_KEY¶
MyMemory access key for private translation memory, use it with MT_MYMEMORY_USER
.
MT_MYMEMORY_USER¶
MyMemory user ID for private translation memory, use it with MT_MYMEMORY_KEY
.
MT_NETEASE_KEY¶
NetEase Sight API 密匙 ,您可以在 https://sight.netease.com/ 注册使用
MT_NETEASE_SECRET¶
NetEase Sight API 的密码,您可以在 https://sight.netease.com/ 上注册
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 注册。
NEARBY_MESSAGES¶
How many strings to show around the currently translated string. This is just a default value, users can adjust this in 用户资料.
RATELIMIT_ATTEMPTS¶
3.2 新版功能.
Maximum number of authentication attempts before rate limiting is applied.
Defaults to 5.
RATELIMIT_WINDOW¶
3.2 新版功能.
How long authentication is accepted after rate limiting applies.
An amount of seconds defaulting to 300 (5 minutes).
RATELIMIT_LOCKOUT¶
3.2 新版功能.
How long authentication is locked after rate limiting applies.
An amount of seconds defaulting to 600 (10 minutes).
REGISTRATION_ALLOW_BACKENDS¶
4.1 新版功能.
List of authentication backends to allow registration from in case it is otherwise disabled by
REGISTRATION_OPEN
.
例:
REGISTRATION_ALLOW_BACKENDS = ["azuread-oauth2", "azuread-tenant-oauth2"]
提示
The backend names match names used in URL for authentication.
REGISTRATION_CAPTCHA¶
A value of either True
or False
indicating whether registration of new
accounts is protected by CAPTCHA. This setting is optional, and a default of
True
will be assumed if it is not supplied.
If turned on, a CAPTCHA is added to all pages where a users enters their e-mail address:
New account registration.
Password recovery.
Adding e-mail to an account.
Contact form for users that are not signed in.
REGISTRATION_EMAIL_MATCH¶
2.17 新版功能.
Allows you to filter which e-mail addresses can register.
Defaults to .*
, which allows any e-mail address to be registered.
You can use it to restrict registration to a single e-mail domain:
REGISTRATION_EMAIL_MATCH = r'^.*@weblate\.org$'
REGISTRATION_OPEN¶
Whether registration of new accounts is currently permitted.
This optional setting can remain the default True
, or changed to False
.
This setting affects built-in authentication by e-mail address or through the
Python Social Auth (you can whitelist certain back-ends using
REGISTRATION_ALLOW_BACKENDS
).
注解
If using third-party authentication methods such as LDAP 身份验证, it just hides the registration form, but new users might still be able to sign in and create accounts.
REPOSITORY_ALERT_THRESHOLD¶
4.0.2 新版功能.
Threshold for triggering an alert for outdated repositories, or ones that contain too many changes. Defaults to 25.
SIMPLIFY_LANGUAGES¶
Use simple language codes for default language/country combinations. For
example an fr_FR
translation will use the fr
language code. This is usually
the desired behavior, as it simplifies listing languages for these default
combinations.
Turn this off if you want to different translations for each variant.
SITE_DOMAIN¶
Configures site domain. This is necessary to produce correct absolute links in many scopes (for example activation e-mails, notifications or RSS feeds).
In case Weblate is running on non-standard port, include it here as well.
示例:
# Production site with domain name
SITE_DOMAIN = "weblate.example.com"
# Local development with IP address and port
SITE_DOMAIN = "127.0.0.1:8000"
注解
This setting should only contain the domain name. For configuring protocol,
(enabling and enforcing HTTPS) use ENABLE_HTTPS
and for changing
URL, use URL_PREFIX
.
提示
On a Docker container, the site domain is configured through
WEBLATE_ALLOWED_HOSTS
.
SITE_TITLE¶
Site title to be used for the website and sent e-mails.
SPECIAL_CHARS¶
Additional characters to include in the visual keyboard, Visual keyboard.
The default value is:
SPECIAL_CHARS = ('\t', '\n', '…')
SINGLE_PROJECT¶
3.8 新版功能.
Redirects users directly to a project or component instead of showing
the dashboard. You can either set it to True
and in this case it only works in
case there is actually only single project in Weblate. Alternatively set
the project slug, and it will redirect unconditionally to this project.
在 3.11 版更改: The setting now also accepts a project slug, to force displaying that single project.
例:
SINGLE_PROJECT = "test"
STATUS_URL¶
The URL where your Weblate instance reports its status.
SUGGESTION_CLEANUP_DAYS¶
3.2.1 新版功能.
Automatically deletes suggestions after a given number of days.
Defaults to None
, meaning no deletions.
URL_PREFIX¶
This setting allows you to run Weblate under some path (otherwise it relies on being run from the webserver root).
注解
To use this setting, you also need to configure your server to strip this prefix.
For example with WSGI, this can be achieved by setting WSGIScriptAlias
.
提示
The prefix should start with a /
.
例:
URL_PREFIX = '/translations'
注解
This setting does not work with Django’s built-in server, you would have to
adjust urls.py
to contain this prefix.
VCS_BACKENDS¶
Configuration of available VCS backends.
注解
Weblate tries to use all supported back-ends you have the tools for.
提示
You can limit choices or add custom VCS back-ends by using this.
VCS_BACKENDS = (
'weblate.vcs.git.GitRepository',
)
参见
VCS_CLONE_DEPTH¶
3.10.2 新版功能.
Configures how deep cloning of repositories Weblate should do.
注解
Currently this is only supported in Git. By default Weblate does shallow clones of the repositories to make cloning faster and save disk space. Depending on your usage (for example when using custom 附加组件), you might want to increase the depth or turn off shallow clones completely by setting this to 0.
提示
In case you get fatal: protocol error: expected old/new/ref, got 'shallow
<commit hash>'
error when pushing from Weblate, turn off shallow clones completely by setting:
VCS_CLONE_DEPTH = 0
WEBLATE_ADDONS¶
List of addons available for use. To use them, they have to be enabled for a given translation component. By default this includes all built-in addons, when extending the list you will probably want to keep existing ones enabled, for example:
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",
# Addon you want to include
"weblate.addons.example.ExampleAddon",
)
参见
WEBLATE_EXPORTERS¶
4.2 新版功能.
List of a available exporters offering downloading translations or glossaries in various file formats.
参见
WEBLATE_FORMATS¶
3.0 新版功能.
List of file formats available for use.
注解
The default list already has the common formats.
参见
WEBLATE_GPG_IDENTITY¶
3.1 新版功能.
Identity used by Weblate to sign Git commits, for example:
WEBLATE_GPG_IDENTITY = 'Weblate <weblate@example.com>'
The Weblate GPG keyring is searched for a matching key (home/.gnupg
under
DATA_DIR
). If not found, a key is generated, please check
Signing Git commits with GnuPG for more details.