ubuntu下安装goldendict及离线词库

1.sudo apt-get install goldendict

2.播放语音
sudo apt-get install mplayer

sudo apt-get install ubuntu-restricted-addons

sudo apt-get install ubuntu-restricted-extras

3.批量解压离线词库

#! /bin/bash
# run this script to install goldendict and off-line dictionaries
# Only for Ubuntu
# created by longbin <beangr@163.com>
# 2014-03-28


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"

goldendict_essential_install
goldendict_offline_dict_setup




4.配置
Preferences  Files  词库位置 /usr/share/goldendict-wordnet/dic
Preferences Audio  Playback  mplayer

5.在线词典

http://www.iciba.com/%GDWORD%/

去在线词典广告,本地新建 dict.html

<!DOCTYPE html>
<html>
<head>
    <meta charset=utf-8 />
    <style>
        iframe{ width: 706px; height: 650px; margin-top:-190px; margin-left:-120px;
        }
    </style>
</head>

<body>
    <iframe id="a" frameborder="0">
    </iframe>
    <script>
    var word = location.href.slice(location.href.indexOf('?a')+3);
    document.getElementById('a').setAttribute(
        'src',
        'http://dict.youdao.com/search?le=eng&q=' + word + '&keyfrom=dict.top');
    </script>
</body>

网站  加入本地地址file:///home/xuefliang/Documents/goldendict_for_ubuntu/dict.html?a=%GDWORD%

评论

此博客中的热门博文

V2ray websocket(ws)+tls+nginx分流

Rstudio 使用代理