Contributing to Weblate modules
Besides the main repository, Weblate consists of several Python modules. All these follow same structure and this documentation covers them all.
For example, this covers:
wlc, Python client library, see Weblate 客户端
translation-finder, used to discover translatable files in the repository
language-data, language definitions for Weblate, see 语言定义
Coding guidelines
在为 Weblate 编写任何代码时都应该考虑到 通过设计保证安全原则 。
Any code should come with documentation explaining the behavior. Don’t forget documenting methods, complex code blocks, or user visible features.
Any new code should utilize PEP 484 type hints. We’re not checking this in our CI yet as existing code does not yet include them.
Running tests
The tests are executed using py.test. First you need to install test requirements:
pip install -r requirements-test.txt
You can then execute the testsuite in the repository checkout:
py.test
参见
The CI integration is very similar to Weblate 测试套件与持续集成.
Coding standard and linting the code
代码应该符合 PEP-8 编码准则,并且应该使用 black 代码格式化程序来格式化。
为了检查代码质量,可以使用 flake8,推荐的插件列在 .pre-commit-config.yaml
中,而其配置放置在 setup.cfg
中。
The easiest approach to enforce all this is to install pre-commit. The
repository contains configuration for it to verify the committed files are sane.
After installing it (it is already included in the
requirements-lint.txt
) turn it on by running pre-commit install
in
Weblate checkout. This way all your changes will be automatically checked.
还能够手动触发检查,来检查所有文件的运行:
pre-commit run --all
参见