如何参与Github上的开源项目Flask-security语言翻译

以项目flask-security为例

Fork 开源项目到自己的账号

  1. 打开https://github.com/并登录自己的账号

  2. 打要参与的开源开项目主页:
    比如 https://github.com/mattupstate/flask-security/

  3. Fork该项目到自己的账户下(点击右上角的Fork按钮)

  4. 打开刚刚Fork的仓库主页(在自己的账号下面)

  5. clone 该仓库到本地,以我自己的账号Steinkuo为例:

    git clone https://github.com/Steinkuo/flask-security.git

    (如果没有设置ssh rsa public key也可以使用https协议)

  6. 切换到相应的分支:

    git checkout develop

    (flask-security项目最新的变更在develop,一般是master)

  7. 翻译文件并上传:

python3 -m venv env

pip install -r requirements.txt

pybabel init -i flask_security/translations/flask_security.pot -d flask_security/translations -l zh_Hans_CN

vim  flask_security/translations/zh_Hans_CN/messages.po
# no compile
# pybabel compile -d flask_security/translations/

git add .
git commit -m "i18n: added Chinese-Simple translation"
# 修改本地代码,提交,最后推送到远程仓库:
git push origin develop
# (flask-security项目最新的变更在develop,一般是master)

提交自己修改的内容到源仓库

  1. 假设你的改动已经推送到自己账户下的远程仓库

  2. 登录github 打开自己Fork的仓库,点击New pull request按钮

  3. 然后会跳转到,原作者的repo下,出现pull request的界面,你就选择一下想要提交的branch就行了,如果有文件可以提交,下面会有commit的按钮,你填一下description就ok了,然后等作者merge。

保持Fork的库和源库代码同步

  1. 查看前面clone下来代码的远程仓库的路径:
    git remote -v

  2. 配置源仓库(开源项目的)的路径:

    (env) ➜  flask-security git:(develop) git remote add upfork [email protected]:mattupstate/flask-security.git
    (env) ➜  flask-security git:(develop) git remote -v
    origin  https://github.com/Steinkuo/flask-security.git (fetch)
    origin  https://github.com/Steinkuo/flask-security.git (push)
    upfork  [email protected]:mattupstate/flask-security.git (fetch)
    upfork  [email protected]:mattupstate/flask-security.git (push)
    
  3. 同步源仓库的提交的变更:

    git fetch upfork
  4. 合并源仓库某个分支的变更到当前本地分支:
     

    git merge upfork/develop


    (flask-security项目最新的变更在develop,一般是master)

  5. 此时,你的本地库已经和源仓库已经完全同步了。但是注意,此时只是你电脑上的本地库和远程的github源仓库同步了,你自己账户的github仓库还没有同步,此时需要使用git push origin master命令把你本地的仓库提交到自己账户的github中。

猜你喜欢

转载自blog.csdn.net/gh254172840/article/details/81364307