首先安装goldendict和goldendict-wordnet
sudo apt-get install goldendict goldendict-wordnet
然后将制作好的离线词库解压到某个目录下,打开goldendict设置词典目录并加载
如果要播放离线词库中的语音,还需要安装mplayer及其解码器
sudo apt-get install mplayer
sudo apt-get install ubuntu-restricted-addons
sudo apt-get install ubuntu-restricted-extras
以上安装步骤及配置离线词库都已经集成在一个压缩包中,解压后执行里面的install_goldendict.sh即可
bash install_goldendict.sh
以下是该压缩包的下载链接,压缩包中包含8个离线词库(牛津,韦氏词典,郎道,21世纪英汉双向词典等)有DSL格式和BGL格式的,共约1.8GB
网盘下载链接: http://pan.baidu.com/s/1dDkyXPJ 密码: cmre
请保存到自己网盘后再下载
配置步骤
效果预览
以下是参考的脚本,需要配合本压缩包使用(压缩包中已经包含该脚本,直接执行即可)
#! /bin/bash
# run this script to install goldendict and off-line dictionaries
# Only for Ubuntu
# created by longbin <beangr@163.com>
# 2014-03-28
## get system distributor ID: Ubuntu ?
UBUNTU_DISTRIBUT=$(cat /etc/issue |tr 'A-Z' 'a-z'|awk '{print $1}')
## get system release: Ubuntu 12.04/14.04 ?
UBUNTU_RELEASE=$(cat /etc/issue | awk '{print $2}' | sed 's/\./\ /g' |awk '$0 {print $1"."$2}')
FILE_LIST="goldendict goldendict-wordnet"
MULTIPLE_SUPPORT="mplayer ubuntu-restricted-addons ubuntu-restricted-extras"
## the off-line dicts directory should put your off-line dicts
OFFLINE_DICTS_DIR=Golden_Offline_dict_with_pic_sounds
function check_user_UID(){
if [[ ${UID} -lt 1000 ]] ;then
echo "Please don't use root to execute this script."
exit
fi
}
## check whether system is Ubuntu 12.04 or 14.04
function check_ubuntu_release(){
case ${UBUNTU_RELEASE} in
12.04)
echo -e "\tCurrent OS: 12.04"
;;
14.04)
echo -e "\tCurrent OS: 14.04"
;;
16.04|18.04)
echo -e "\tCurrent OS: ${UBUNTU_RELEASE}"
;;
*)
echo "Only support Ubuntu LTS version, eg: 12.04/14.04/16.04 ..."
exit 1
;;
esac
echo "checked OK, preparing to setup system ..."
sleep 2
}
## check whether system is Ubuntu or not
function check_system_distributor(){
echo "checking distributor and release ID ..."
if [[ "${UBUNTU_DISTRIBUT}" == "ubuntu" ]] ;then
echo -e "\tCurrent OS: ${UBUNTU_DISTRIBUT}"
check_ubuntu_release
else
echo -e "\tCurrent OS is not ubuntu"
echo -e "\tCurrent OS: ${UBUNTU_DISTRIBUT}"
echo -e "\tExit."
exit
fi
}
function goldendict_essential_install(){
for file in ${FILE_LIST}
do
trap 'echo -e "\nInterrupted by user"; exit' INT
echo -e "\n======================================="
echo -e "Preparing to install ${file} ..."
echo -e "======================================="
echo -e "\tsudo apt-get install ${file}"
sudo apt-get install ${file}
done
RET_VAL=$(which goldendict)
if [[ "${RET_VAL}" == "" ]] ;then
echo "goldendict installed error."
exit
else
echo "goldendict installed successfully."
fi
}
function select_offline_dict_dir(){
read -p "Press <Enter> to install off-line dictionaries. "
if [[ -d "${OFFLINE_DICTS_DIR}" ]] ;then
return
fi
DIR_LIST=$(find . -maxdepth 3 -type d | sed '/^\.$/d' | sed 's#\./##')
if [[ "${DIR_LIST}" == "" ]] ;then
echo "Off-line dictionary directory not exists."
exit
fi
PS3="Please select your goldendict off-line dictionary's dir: "
select option in ${DIR_LIST}
do
if [[ -d "${option}" ]] ;then
OFFLINE_DICTS_DIR=${option}
break
fi
done
}
function goldendict_offline_dict_setup(){
select_offline_dict_dir
GOLDENDICT_OFFLINE_DICT_DIR=/usr/share/goldendict-wordnet/dic
if ! [[ -d "${GOLDENDICT_OFFLINE_DICT_DIR}" ]] ;then
sudo mkdir -p ${GOLDENDICT_OFFLINE_DICT_DIR}
fi
if [[ -d ${OFFLINE_DICTS_DIR} ]] ; then
pushd ${OFFLINE_DICTS_DIR}
###########################
TGZ_FILES=$(ls |grep tgz)
if [[ "${TGZ_FILES}" == "" ]] ;then
echo "None tgz file exists."
exit
fi
for file in ${TGZ_FILES}
do
if [[ -d "${GOLDENDICT_OFFLINE_DICT_DIR}/${file%.tgz}" ]] ;then
echo "directory ${GOLDENDICT_OFFLINE_DICT_DIR}/${file%.tgz} has already exist."
sudo rm -rf ${GOLDENDICT_OFFLINE_DICT_DIR}/${file%.tgz}
fi
echo "tar -zxvf ${file} -C ${GOLDENDICT_OFFLINE_DICT_DIR}"
sudo tar -zxvf ${file} -C ${GOLDENDICT_OFFLINE_DICT_DIR}
done
##########################
popd
else
echo "Off-line dictionary directory \"${OFFLINE_DICTS_DIR}\" not exists."
echo 'Please download dictionaries to \"${OFFLINE_DICTS_DIR}\" '
fi
}
function install_mplayer_mutiple_support(){
for file in ${MULTIPLE_SUPPORT} ${MULTIPLE_SUPPORT}
do
echo -e "\n======================================="
echo -e "Preparing to install ${file} ..."
echo -e "======================================="
echo -e "\tsudo apt-get install ${file} ..."
sudo apt-get install ${file}
done
}
echo "Preparing to install goldendict and off-line dictionaries"
check_user_UID
check_system_distributor
goldendict_essential_install
goldendict_offline_dict_setup
install_mplayer_mutiple_support
Fedora下安装星际译王及其词库:http://www.linuxdiyf.com/linux/9721.html
Linux下星际译王离线词库:http://www.linuxdiyf.com/linux/5679.html