贡献者指南
欢迎使用 Casdoor。本指南介绍如何进行贡献。
对于文档中的错误或遗漏信息,请提交 Issue 或建议编辑。
参与进来
贡献方式:
- 使用 Casdoor 并报告问题。 对于 Bug 或功能建议,请先在 GitHub Discussions 或 Discord 中讨论,然后再提交 GitHub Issue。
报告问题时,请用 English 描述问题。
-
改进文档。 文档修正和澄清是很好的首个贡献。
-
处理 Issues。 Casdoor Easy Tasks 列出了不同难度级别的适合初学者的 Issues。
提交更改
当你准备好贡献代码或文档时:
- 将仓库 Fork 到你的账户。
- 在本地克隆你的 Fork。
- 创建一个新分支并进行修改。
- 保持你的分支与上游 master 分支同步。
- 使用清晰、简洁的消息进行 Commit。
- 将你的分支推送到你的 Fork。
- 从你的分支向 master 分支发起 Pull Request。
Pull Requests
开始之前
- 在首次发起 Pull Request 时,你必须签署 CLA(贡献者许可协议)。
- 描述 PR 的目的及其更改内容。
- 每个 PR 仅包含一个逻辑变更。 如果 PR 做了多个不相关的事情,请将其拆分为多个 PR。
- 每个 PR 仅包含一个 Commit。 将你的更改压缩(Squash)为单个 Commit。
- 对于新文件,请在顶部添加 Casdoor 许可证头。
// Copyright 2022 The Casdoor Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
约定式提交 (Conventional Commits)
PR 标题(以及提交信息)应遵循 约定式提交 规范。
PR 标题必须为小写。
示例:
- fix — Bug 修复:
fix: prevent racing of requests - feat — 新功能:
feat: allow provided config object to extend other configs - docs — 文档:
docs: correct spelling of CHANGELOG
完整规范请参见 约定式提交。
将 PR 链接到 Issue
将 PR 链接到 Issue,以便在合并 PR 时自动关闭该 Issue。在 PR 描述或默认分支上的提交信息中,使用以下关键字之一后跟 Issue 编号:close、fix 或 resolve。
示例:Fix: #902
参见 GitHub: Linking a pull request to an issue。
更新你的 PR
如果评审者要求修改,请更新同一个 PR,而不是关闭它并打开一个新的 PR:
- 在本地进行修改。
- 修改提交:
git commit --amend - 推送:
git push --force
代码指南
- 可读性: 重要逻辑应有文档说明。遵循项目中现有的代码风格。
命名
- 代码: camelCase(例如
signupUrl)。 - UI 字符串: Title Case 且包含空格(例如 “Signup URL”)。
更新 i18n 数据
我们使用 Caslingo 和 i18next 进行翻译。当你在 web/ 目录下通过 i18next 添加新的 UI 字符串时,运行:
cd i18n && go test
这将重新生成 web/src/locales/**/data.json。新键默认填充英文。PR 合并后,Caslingo 会机器翻译新键并提交;你可以在 Caslingo 上建议更好的翻译。
不要翻译成你不确定的语言;保留默认值(英文)不变。
命名空间约定
翻译键按命名空间组织。为键使用最具体的命名空间——不要将特定领域的字符串放在 general: 中。
| 命名空间 | 范围 |
|---|---|
general | 真正通用的 UI 词汇(例如 Save, Cancel) |
auth | 登录、注册、MFA、密码流程 |
provider | OAuth, SAML, LDAP 及其他提供商 |
payment | 产品、订单、支付、订阅 |
subscription | 订阅相关字符串 |
添加新键时,请先检查更具体的命名空间中是否已存在该键,然后再将其添加到 general 中。
去重测试
i18n/ 目录包含用于捕获跨命名空间重复键的测试:
cd i18n && go test -run TestDeduplicateFrontendI18n
cd i18n && go test -run TestDeduplicateBackendI18n
TestDeduplicateFrontendI18n 扫描 web/src/locales/,TestDeduplicateBackendI18n 扫描后端区域设置文件。如果某个键出现在 general 中,而更具体的命名空间已经定义了它,则这两个测试都会失败。在提交涉及翻译文件的 PR 之前,请运行这些测试。
许可证
通过贡献代码,您同意您的贡献将在 Apache 许可证下获得授权。