Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
m986883511 opened this issue Sep 4, 2023 · 0 comments
Open

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

m986883511 opened this issue Sep 4, 2023 · 0 comments

Comments

@m986883511
Copy link

我模仿了该项目为公司开发部署底层软件的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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant