Simplify or not to simplify, this is a question.
超级无敌全能forturn-zh脚本:
#!/bin/bash
# fortune-zh V1.0
#
# Copyright (C) 2006 Zhang Le
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
FORTUNE="/usr/bin/fortune"
CMD=`basename "$0"`
if [ -f "${HOME}"/.fortune-zh.conf ] ; then
CONF="${HOME}"/.fortune-zh.conf
elif [ -f /etc/fortune-zh.conf ]; then
CONF=/etc/fortune-zh.conf
fi
if [ -z $CONF ] || [ ! -s $CONF ] ; then
exec $FORTUNE
fi
if [ ! -z $LC_ALL ]
then
LANG="$LC_ALL"
fi
CHARSET=`echo ${LANG#*.} | tr A-Z a-z | sed -e 's/-//g'`
if [ $# -eq 0 ] ; then
DICT=`cat ${CONF}`
else
DICT=`echo $@ | sed -e 's/[^0-9% ]\+/zh-&/g'`
fi
if test $CMD == "fortune-zh"; then
case "$CHARSET" in
big5)
LC_ALL=zh_CN.GB18030 $FORTUNE $DICT | autob5
;;
*)
$FORTUNE $DICT
;;
esac
elif test $CMD == "fortune-sc"; then
case "$CHARSET" in
big5)
echo 'Not available in BIG5 environment, try UTF-8'
;;
*)
$FORTUNE $DICT
;;
esac
elif test $CMD == "fortune-tc"; then
case "$CHARSET" in
gb*)
echo 'Not available in GB environment, try UTF-8'
;;
big5)
LC_ALL=zh_CN.GB18030 $FORTUNE $DICT | autob5
;;
utf8)
LC_ALL=zh_CN.GB18030 $FORTUNE $DICT | autob5 | autogb -i big5 -o utf8
;;
esac
fi
Traditional Chinese
《行路難》
作者:李白
金樽清酒鬥十千,玉盤珍饈直萬錢。
停杯投箸不能食,拔劍四顧心茫然。
欲渡黃河冰塞川,將登太行雪暗天。
閒來垂釣坐溪上,忽復乘舟夢日邊。
行路難,行路難,多歧路,今安在。
長風破浪會有時,直掛雲帆濟滄海。
Simplified Chinese
《行路难》
作者:李白
金樽清酒斗十千,玉盘珍馐直万钱。
停杯投箸不能食,拔剑四顾心茫然。
欲渡黄河冰塞川,将登太行雪暗天。
闲来垂钓坐溪上,忽复乘舟梦日边。
行路难,行路难,多歧路,今安在。
长风破浪会有时,直挂云帆济沧海。
#!/bin/bash
# fortune-zh V1.0
#
# Copyright (C) 2006 Zhang Le
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
FORTUNE="/usr/bin/fortune"
CMD=`basename "$0"`
if [ -f "${HOME}"/.fortune-zh.conf ] ; then
CONF="${HOME}"/.fortune-zh.conf
elif [ -f /etc/fortune-zh.conf ]; then
CONF=/etc/fortune-zh.conf
fi
if [ -z $CONF ] || [ ! -s $CONF ] ; then
exec $FORTUNE
fi
if [ ! -z $LC_ALL ]
then
LANG="$LC_ALL"
fi
CHARSET=`echo ${LANG#*.} | tr A-Z a-z | sed -e 's/-//g'`
if [ $# -eq 0 ] ; then
DICT=`cat ${CONF}`
else
DICT=`echo $@ | sed -e 's/[^0-9% ]\+/zh-&/g'`
fi
if test $CMD == "fortune-zh"; then
case "$CHARSET" in
big5)
LC_ALL=zh_CN.GB18030 $FORTUNE $DICT | autob5
;;
*)
$FORTUNE $DICT
;;
esac
elif test $CMD == "fortune-sc"; then
case "$CHARSET" in
big5)
echo 'Not available in BIG5 environment, try UTF-8'
;;
*)
$FORTUNE $DICT
;;
esac
elif test $CMD == "fortune-tc"; then
case "$CHARSET" in
gb*)
echo 'Not available in GB environment, try UTF-8'
;;
big5)
LC_ALL=zh_CN.GB18030 $FORTUNE $DICT | autob5
;;
utf8)
LC_ALL=zh_CN.GB18030 $FORTUNE $DICT | autob5 | autogb -i big5 -o utf8
;;
esac
fi
Traditional Chinese
《行路難》
作者:李白
金樽清酒鬥十千,玉盤珍饈直萬錢。
停杯投箸不能食,拔劍四顧心茫然。
欲渡黃河冰塞川,將登太行雪暗天。
閒來垂釣坐溪上,忽復乘舟夢日邊。
行路難,行路難,多歧路,今安在。
長風破浪會有時,直掛雲帆濟滄海。
Simplified Chinese
《行路难》
作者:李白
金樽清酒斗十千,玉盘珍馐直万钱。
停杯投箸不能食,拔剑四顾心茫然。
欲渡黄河冰塞川,将登太行雪暗天。
闲来垂钓坐溪上,忽复乘舟梦日边。
行路难,行路难,多歧路,今安在。
长风破浪会有时,直挂云帆济沧海。
Comments