# Bitcoin Optech 中文翻译贡献流程 {%hackmd theme-dark %} ## 0. 环境准备 安装所需要的软件: - git - ruby 安装部署过程参考 [Optech 文档](https://github.com/bitcoinops/bitcoinops.github.io#building-the-site-locally)。 另外,需要准备 Github 账号,并加入[翻译组](https://github.com/orgs/PrimitivesLane/teams/translator)。 将远端库的内容 clone 到本地: ```shell git clone https://github.com/PrimitivesLane/bitcoinops.github.io.git ``` ## 1. 相关仓库及翻译整体流程 ### 各仓库及其关系 - 远端库(`PrimitivesLane/bitcoinops.github.io`)翻译 - 上游库(`bitcoinops/bitcoinops.github.io`)贡献翻译内容 仓库间的关系如下: ``` ┌────────────────┐ ┌─────────────────┐ ┌──────────────┐ │ │ │ │ │ │ │ bitcoinops │ │ PrimitivesLane │ │ local │ │ ├──────┤ ├──────┤ │ │ repo │ │ repo │ │ repo │ │ │ │ │ │ │ └────────────────┘ └─────────────────┘ └──────────────┘ upstream origin local ``` ### 翻译整体流程 - 翻译准备:更新远端库并在本地库准备好分支 - 翻译并推送 - 提交 PR ## 2. 翻译准备 在新一期的 Optech 发布后,首先更新远端库(`PrimitivesLane/bitcoinops.github.io`),将远端库更新到与上游库(`bitcoinops/bitcoinops.github.io`)同步。 操作方法: - 在 Github [界面](https://github.com/PrimitivesLane/bitcoinops.github.io/tree/master)上点击 "Sync fork" 在本地拉取最新的远端库的代码: ```shell git pull ``` ### 创建翻译的分支 ```shell git checkout -b newsletter<number>d1 git push ``` 例如,待翻译的是 `236` 期,则命令为: ```shell git checkout -b newsletter236d1 git push ``` ### 创建翻译的工作分支 ```shell git checkout -b newsletter<number>d2 git push ``` 例如,待翻译的是 `236` 期,则命令为: ```shell git checkout -b newsletter236d2 git push ``` ## 3. 翻译 ### 创建文件 最新一期英文周报文件在`_posts/en/newsletters/` 下。需要将该文件复制到中文周报目录:`_posts/zh/newsletters/`。 ### 修改文件头 正式开始翻译前,需要在文件头中的: - `permalink` 的前缀改为 `zh` - `name`、`slug` 后增加 `-zh` - `lang` 的内容修改为 `zh` 以下是修改后的示例: ```markdown --- title: 'Bitcoin Optech Newsletter #236' permalink: /zh/newsletters/2023/02/01/ name: 2023-02-01-newsletter-zh slug: 2023-02-01-newsletter-zh type: newsletter layout: newsletter lang: zh --- ``` ### 翻译并编译 接下来就可以正式开始翻译工作了。 翻译完成后,需要在本地仓库的根目录下执行。 ```shell make production ``` 如果格式等全部正确,则应该会编译成功;否则,需要按照报错信息以及下一节的注意事项,检查并修改。 (可选的)如果要预览最终效果,可以执行以下命令,并在浏览器中访问:“http://0.0.0.0:4000/ ” ```shell make preview ``` ### 格式注意事项: 编译对格式的要求较严。如果不符合规范,则会编译不通过。以下是一些常见的格式问题: - 多个无序列表(bulletpoints)行之间需要空一行 - 二级无序标题需要将 `-` 改为 `*` - 没有内容的空白行不能有空格(space)字符或制表符(tab) - 引用内容如果是之前的周报并且有对应的中文翻译版本时,需要将英文链接改为对应的中文链接 - 无序列表的标题(行首的加粗文字内容)如果是纯中文的,则需要增加英文注释 例如,下文中的无序列表的标题只有中文:“闪电网络异步支付证明:” ```markdown - **闪电网络异步支付证明:**如[上周周报][news235 async] 中所述…… ``` 这种情况下,需要增加对应的英文注释(可从英文原文中摘取),以便编译后可产生锚点链接,如下所示: ```markdown - **<!--ln-async-proof-of-payment-->闪电网络异步支付证明:**如[上周周报][news235 async] 中所述…… ``` ## 4. 提交 PR ### 本地提交并推送 ```shell git add . git commit -m "newsletter-236: translate into Chinese" git push ``` ### 提交 PR 到远端库(PrimitivesLane) 在远端库的 [PR 页面](https://github.com/PrimitivesLane/bitcoinops.github.io/pulls)点击 “New pull request”。 此时需要注意在 “base repository” 中选择 “PrimitivesLane/bitcoinops.github.io”。 然后在 “base” 中选择 d1 分支(例如 `newsletter236d1`)。 在 “compare” 中选择 d2 分支(例如 `newsletter236d2`)。 然后填写标题等内容(例如 “Newsletter-236: translate into Chinese”)。 确认无误后,提交。 ## 5. 审核及推送上游的流程 后续的流程翻译者一般不需要关心。 流程为: - [freeyao](https://github.com/freeyao) 会审核、修改 - [hulatown](https://github.com/hulatown) 会进行合并分支到 d1 之后推送到上游分支 至此,一期周报即翻译完成。