ivanhao / pvetools

proxmox ve tools script(debian9+ can use it).Including email, samba, NFS set zfs max ram, nested virtualization ,docker , pci passthrough etc. for english user,please look the end of readme.
GNU General Public License v3.0
4.1k stars 501 forks source link

是故意写成一个单文件的吗? #87

Open m986883511 opened 10 months ago

m986883511 commented 10 months ago

我模仿了该项目为公司开发部署底层软件的tui 将单文件拆成了,业务代码1,2,3,翻译文件和界面逻辑,这样更清晰,也更方便别人贡献代码。

这是我的翻译函数 cat text

hello
你好
zhongyingwen
中英文
fanyi
翻译
PveTools   Version : 2.3.7 
PVE工具箱
Install Ceph

翻译函数

function i18n() {
    local result
    local line
    local content
    local text_file="./text"
    result=$(grep -n "^$1" $text_file)
    if [ -z "$result" ]; then
        echo "$1(not translate)"
    else
        line=$(echo "$result" | cut -d ':' -f 1)
        if [ "$L" = 'zh' ];then
            line=$(($line + 1))
        fi
        content=$(sed -n "$line"p "$text_file")
        echo $content
    fi
}

界面逻辑文件中具体使用

    OPTION=$(whiptail --title "$TOOLS_TITTLE" --menu "$(i18n 'Please choose:')" 25 60 15 \
    "c" "$(i18n 'Ceph Base Env')" \
    "o" "$(i18n 'Openstack Base Env')" \
    "r" "$(i18n 'Go Back')" \
    3>&1 1>&2 2>&3)