自动更新handbook翻译进度表的脚本

首先,说明一下我准备把 http://r0bertz.blogspot.com 加入 gentoo planet。
那样意味着以后r0bertz.blogspot.com上所有的文章都将用英文来写,专注于技术相关的话题。
鉴于我们伟大的防火长城间歇性的屏蔽blogspot,建议使用抓虾、google reader等来订阅这个blog。
zhllg.spaces.msn.com就用来写一些非技术话题,用中文写。
给zhlly说声抱歉,zhllg.livejournal.com我要回来也没有怎么好好利用。不过我还没有归还的打算。问题的关键在于,我不想让别人误解我转投了fedora core的阵营,;)

刚刚写了个脚本来更新handbook翻译进度表
http://gentoo.linuxsir.org/doc/progress.xml#doc_chap4
如果发现英文版有了新版本,就更新表格中英文版的版本和日期,并且把进度改成W,完成期限置空

我的xml技术了解不是很深,这样处理xml,似乎很不专业
就当抛砖引玉了
getdate() {
grep Header $1 | egrep -o '200[0-9]/[0-9]{2}/[0-9]{2}'
}
getver() {
grep Header $1 | egrep -o 'v [0-9]+\.[0-9]+'
}

PREFIX=/home/zhangle/gentoo/xml/htdocs/

for i in `grep -o '/doc/en/handbook/.*\.xml' progress.xml`
do
olddate=$(grep -A 1 $i progress.xml | egrep -o 200[0-9]/[0-9]\{2\}/[0-9]\{2\})
newdate=$(getdate $PREFIX$i)

if [[ $olddate != $newdate ]]; then
j=${i//\//\\\/}

sed -i -e "
/$j/ {
N
N
s#$i.*\n <ti>200[0-9]/[0-9]\{2\}/[0-9]\{2\}#$i\">$(getver $PREFIX$i)</uri></ti>\n <ti>$newdate#
N
/<ti>T<\/ti>/ {
N
s#<ti>T</ti>\n <ti>200[0-9]/[0-9]\{2\}/[0-9]\{2\}</ti>#<ti>W</ti>\n <ti></ti>#
}
} " progress.xml
fi
done

Comments

Anonymous said…
ZL兄的正则表达式运用纯熟啊~
我也想抽空帮忙翻译,咋领任务呢?
r0bertz said…
目前还有ia64架构的文档无人认领,兄台是否有兴趣?

Popular posts from this blog

The diff between the original SEC complaint against Ripple and the amended one

Send $SGB (Songbird) to another wallet using a script

Rippled thread cpu usage