為 Weblate 模組作出貢獻

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:

Writing a good patch

Write separate changes

It is annoying when you get a massive patch that is said to fix 11 odd problems, but discussions and opinions do not agree with 10 of them or 9 of them were already fixed differently. Then the person merging this change needs to extract the single interesting patch from somewhere within the massive pile of sources, and that creates a lot of extra work.

Preferably, each fix that addresses an issue should be in its own patch/commit with its own description/commit message stating exactly what they correct so that all changes can be selectively applied by the maintainer or other interested parties.

Furthermore, separate changes enable bisecting much better for tracking issues and regression in the future.

文件

Documentation can be a tedious task; however, it is necessary for someone to complete it. It makes things a lot easier if you submit the documentation together with code changes. Please remember to document methods, complex code blocks, or user-visible features.

Test cases

The tests allow us to quickly verify that the features are working as they are supposed to. To maintain this situation and improve it, all new features and functions that are added need to be tested in the test suite. Every feature that is added should get at least one valid test case that verifies that it works as documented.

送交訊息

Git commits should follow Conventional Commits specification.

Coding standard and linting the code

The code should follow PEP 8 coding guidelines and should be formatted using ruff code formatter.

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.

To check the code quality, you can use ruff, its configuration is stored in 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

Coding securely

編寫 Weblate 的任何代碼應該時刻記得 Security by Design Principles (由設計原理來提供安全性)。

AI guidelines

When contributing content to the project, you give us permission to use it as-is, and you must make sure you are allowed to distribute it to us. By submitting a change to us, you agree that the changes can and should be adopted by the project and get redistributed under the project license. Authors should be explicitly aware that the burden is on them to ensure no unlicensed code is submitted to the project.

This is independent of whether AI is used or not.

When contributing a pull request, you should, of course, always make sure that the proposal is of good quality and the best effort that follows our guidelines. A basic rule of thumb is that if someone can spot that the contribution was made with the help of AI, you have more work to do.

We can accept code written with the help of AI into the project, but the code must still follow coding standards, be written clearly, be documented, feature test cases, and adhere to all the normal requirements we have.

也參考

The CI integration is very similar to Weblate 測試套件與連續整合.

也參考

Weblate 來源碼