-
Notifications
You must be signed in to change notification settings - Fork 235
/
language_helper.sh
executable file
·56 lines (46 loc) · 1.18 KB
/
language_helper.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Xiaoxin sGSI Build Tools - Multi Language Helper
# Copyright (C) 2021 Xiaoxindada <2245062854@qq.com> && Jiuyu <2652609017@qq.com>
LANGDIR=`cd "$( dirname ${BASH_SOURCE[0]} )" && pwd`
helper_usage(){
echo "$0 <language>"
echo "Support list:"
dump_support_lang
exit 1
}
dump_support_lang(){
echo "1.简体中文 (Simplified Chinese)"
echo "2.English"
}
CURRENT_LANG=$(echo $LANG | awk -F . '{print $1}')
TARGET_LANG="$1"
BASE_NAME="language_helper.sh"
if [[ ("$1" == "-h" && $BASE_NAME == $(basename $0)) || ("$1" == "--help" && $BASE_NAME == $(basename $0)) ]]; then
helper_usage
exit 1
fi
case $TARGET_LANG in
"zh_CN"|"Chinese")
source $LANGDIR/lang/zh_CN
echo "Support list:"
dump_support_lang
echo
echo $TARGET_LANG
echo $LANG_AUTHOR
echo "zh_CN" > $LANGDIR/.lang_flag
;;
"en_US"|"English")
source $LANGDIR/lang/en_US
echo "Support list:"
dump_support_lang
echo
echo $TARGET_LANG
echo $LANG_AUTHOR
echo "en_US" > $LANGDIR/.lang_flag
;;
esac
if [ ! -f $LANGDIR/.lang_flag ]; then
echo "Can't find $LANGDIR/.lang_flag use zh_CN language by default"
echo "zh_CN" > $LANGDIR/.lang_flag
fi
source $LANGDIR/lang/$(cat $LANGDIR/.lang_flag)