为 Weblate 模块作贡献#
除了主仓库之外Weblate 还包含几个 Python 模块,所有这些都遵循相同的结构本文档涵盖了所有这些。
例如,这涵盖了:
wlc,Python 客户端库,请参阅 Weblate 客户端
translation-finder 用于发现仓库中的可翻译文件
language-data,Weblate 的语言定义,请参见 语言定义
代码编写准则#
在为 Weblate 编写任何代码时都应该考虑到 通过设计保证安全原则。
任何代码都应附带解释行为的文档。不要忘记记录方法、复杂的代码块或用户可见的功能。
任何新代码都应使用 PEP 484 类型提示。我们尚未在 CI 中检查此项,因为现有代码尚未包含它们。
运行测试#
测试使用:program:`py.test`执行,首先你需要安装测试需求:
pip install -e '.[test,lint]'
然后您可以在仓库签出中执行测试套件:
py.test
参见
CI 集成与 Weblate 测试套件与持续集成 非常相似。
编码标准和代码检查#
代码应该遵循 PEP-8 代码编写准则,并且应该使用 ruff 代码格式化程序进行代码格式化。
要检查代码质量,你可以使用 ruff,其配置存储在 pyproject.toml
中。
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
pyproject.toml
) turn it on by running pre-commit install
in
Weblate checkout. This way all your changes will be automatically checked.
还能够手动触发检查,来检查所有文件的运行:
pre-commit run --all
参见