為 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:
wlc, Python client library, see Weblate 用戶端
translation-finder, used to discover translatable files in the repository
language-data, language definitions for Weblate, see 語言定義
translate-toolkit, the library to manipulate the translation files, originally third-party library but now maintained by Weblate.
擴展內建語言定義¶
The language definitions are in the language-data repository.
You are welcome to add missing language definitions to languages.csv,
other files are generated from that file. The columns in the CSV file correspond to
語言定義.
授權與版權¶
When contributing project code, you agree to put your changes and new code under the repository license, GPL-3.0-or-later, unless stated and agreed otherwise. New source files should follow the existing copyright and SPDX license header style.
Use a different license only when there is a deliberate reason, such as files shared with repositories using more permissive licenses.
也參考
Weblate 授權 explains licensing in more details.
Writing a good patch¶
寫入單獨的變更¶
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.
測試案例¶
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.
類型檢查¶
Any new code should utilize PEP 484 type hints. We are using mypy to check them because it has a Django plugin that makes type checking of Django apps practical.
New and changed code should not introduce new mypy failures where current Django typing support makes that practical. The code base is not yet completely covered by type annotations, and some Django constructs are difficult to annotate precisely. CI therefore enforces mypy only for selected modules and reports other findings separately.
Coding standard and linting the code¶
程式碼應該符合 PEP 8 變成指導原則,並且應該使用 ruff 程式碼格式化器來格式化。
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 prek. This is
a third-party reimplementation of the pre-commit tool used by Weblate. It is
included in the development dependencies declared in pyproject.toml, so
installing those dependencies makes prek available.
To check all files manually, run:
uv run prek run --all-files
If you prefer the original pre-commit client, it uses the same
configuration from .pre-commit-config.yaml.
安全地編碼¶
編寫 Weblate 的任何代碼應該時刻記得 Security by Design Principles (由設計原理來提供安全性)。
AI 指導原則¶
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.