A workflow of translation projects with VCS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A-Z | |
=== | |
A brown fox jumped over a lazy dog. | |
a brown fox jumped over a lazy dog. | |
A brown fox jumped over a lazy dog. | |
A brown fox jumped over a lazy dog. | |
A brown fox jumped over a lazy dog. | |
029 | |
=== | |
6180339887 4989484820 4586834365 6381177203 0917980576 | |
2862135448 6227052604 6281890244 9707207204 1893911374 | |
8475408807 5386891752 1266338622 2353693179 3180060766 | |
7263544333 8908659593 9582905638 3226613199 2829026788 | |
0675208766 8925017116 9620703222 1043216269 5486262963 | |
1361443814 9758701220 3408058879 5445474924 6185695364 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
_EN=sandbox-en | |
_ZH=sandbox-zh | |
# 始化测试用的源版本库 | |
init() { | |
mkdir $1 | |
cp content $1/README.md | |
pushd . | |
cd $1 | |
git init | |
git add README.md | |
git commit -m "init repo" | |
popd | |
} | |
# clone 并翻译 | |
translate() { | |
git clone $1 $2 | |
pushd . | |
cd $2 | |
sed -i 's/^[aA] brown.*/一只棕色的狐狸跳过一只懒狗。/' README.md | |
sed -i 's/^029/零到九/' README.md | |
git commit -m "翻译" -a | |
popd | |
} | |
# 上游源作了一些变更 | |
modify() { | |
pushd . | |
cd $1 | |
sed -i 's/^a/A/' README.md | |
sed -i 's/^029/0-9/' README.md | |
git commit -m "twisting" -a | |
popd | |
} | |
# 翻译内容进行同步 | |
merge() { | |
pushd . | |
cd $1 | |
git pull | |
# 使用默认对比工具,推荐 meld 之类的支持三方对比的 | |
git mergetool -y | |
if [ $? == 0 ]; then | |
git commit -m "内容更新" | |
else | |
echo '自动合并失败,请手工执行以下命令进行合并和提交:' | |
echo '$ git mergetool' | |
echo '$ git commit -m "内容更新"' | |
fi | |
popd | |
} | |
prompt() { | |
printf "\n$1\n" | |
read -n1 -p $'按任意键继续,或按 Ctrl+C 退出' | |
} | |
check() { | |
[ ! -d $1 ] && return | |
while true; do | |
echo | |
read -n1 -p $"$1 已经存在,是否删除[y/n]" a | |
case $a in | |
[Yy]* ) rm -rf $1; break;; | |
[Nn]* ) return;; | |
* ) echo "请输入 [YyNn]";; | |
esac | |
done | |
} | |
check $_EN | |
check $_ZH | |
prompt "初始化测试用的源版本库 $_EN" | |
init $_EN &> /dev/null | |
printf "==完成==\n" | |
prompt "clone $_EN 到 $_ZH 并翻译" | |
translate $_EN $_ZH &> /dev/null | |
printf "==完成==\n" | |
prompt "对 $_EN 进行修改," | |
modify $_EN &> /dev/null | |
printf "==完成==\n" | |
prompt "将修改使用三方对比的方式合并到 $_ZH" | |
merge $_ZH &> /dev/null | |
printf "==完成==\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment