开源项目翻译正确姿势

日常开发中,我们经常会在Github上发现一些好用的新框架, 如何对这些项目文档进行翻译, 其实这个问题困扰了我很久. 这里,我总结了一些不同情况下所谓的最佳实践, 供大家参考:

独立文档项目

举例: https://github.com/graphql/gr...

GraphQL文档的网站, 是一个独立的项目, source分支是源码目录, master分支(可以理解为gh-pages分支)是静态站点.

1. 初始化翻译项目

直接Fork该项目, 示例: https://github.com/willin/gra...

Fork之后可以给该项目改名, 如我换到了 graphql.js.cool 域名, 并以该域名进行命名.

然后, 将项目Clone至本地.

git clone git@github.com:willin/graphql.js.cool.git
cd graphql.js.cool
# 默认源码的分支是source, 可以新建一个分支用于翻译
git checkout -b cn
git push -u origin cn

至此, 可以开始翻译工作了.

2. 从源站更新内容

# 一次性添加
git remote add remote git@github.com:graphql/graphql.github.io.git
# 每次更新源站最新代码
git pull remote source

.git/config文件参考:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = git@github.com:willin/graphql.js.cool.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "cn"]
    remote = origin
    merge = refs/heads/cn
[travis]
    slug = willin/graphql.js.cool
[remote "remote"]
    url = git@github.com:graphql/graphql.github.io.git
    fetch = +refs/heads/*:refs/remotes/remote/*

文档包含在项目中

可能是一个一个单独的分支, 或者只是某个分支的一个目录.

vue-router项目为例, 文档位于dev分支的docs目录: https://github.com/vuejs/vue-...

1. 初始化翻译项目

git init
git remote add origin xxx # 你的项目路径
git remote add remote git@github.com:vuejs/vue-router.git
# 拉取源站代码
git pull remote dev

2. 从源站更新内容

# 每次更新源站最新代码
git pull remote dev

注意事项

  • CNAME等配置文件需要替换
  • pull后可能会有冲突. 解决后再提交代码.

p.s.

优秀的中文翻译项目及推荐的未翻译项目汇总: Awesome-CN

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下展示部分源码,需要完整版的请下载文件 <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> <style> *{margin:0;padding:0;list-style:none} body{background:#ccc;} .wrap{margin:100px auto;width:900px;height:300px;box-shadow:0 0 4px #434343;background:#fff;padding:20px;border-radius:10px;} .wrap .language{position:relative;width:100px;height:30px;padding:0 30px;margin:20px;text-align:center;line-height:30px;border:1px solid #434343;cursor:pointer;} .wrap .language .languages{position:absolute;top:30px;left:-1px;width:354px;height:auto;border:1px solid #434343;display:none;background:#fff;color:#fff;line-height:40px} .wrap .language .languages ul li{float:left;width:78px;height:40px;margin:4px; border:1px dashed #ccc;background:#368;} .wrap .input, .wrap .show{width:430px;height:150px;float:left;background:#fff; color:#000;margin:10px;box-shadow:0 0 4px #222;line-height:40px;font-size:20px;text-indent:10px;color:#333;font-family:'微软雅黑';} .wrap .input textarea{z-index:3;height:100%;width:400px;border:0;resize:none;outline:0;color:#333;font-family:'微软雅黑';margin:0;padding:0;line-height:40px;font-size:20px;text-indent:10px;} .wrap span.btn{width:140px;height:30px;float:right;margin:10px;line-height:30px;text-align:center;background:#368;box-shadow:0 0 4px #ccc;border-radius:5px;color:#fff;cursor:pointer;} </style>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值