-
Notifications
You must be signed in to change notification settings - Fork 634
/
localize.sh
executable file
·92 lines (81 loc) · 2.52 KB
/
localize.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
function usage {
echo -e "Usage: `basename $0` action parameters"
echo
echo -e "Actions:"
echo -e " sort [lang]: sorts the specified localization file after modification"
echo -e " status [lang]: verifies the localization status of lang"
echo -e " missing [lang]: get a report of missing strings to localize for the lang"
echo -e " all [lang]: get a report of all the localized strings for lang"
echo -e " extend [lang] [extension_txt]: extends the localization with a localized report"
echo
echo -e "A report is in the format:"
echo -e " lang.manage_users.manage = \"Verwalten\""
echo -e " lang.manage_users.manage_user_x = \"Verwalte User %{user}\""
echo -e " ..."
exit 1
}
# pro root
base_path="../tools/localization"
root_path=".."
if [[ -d src ]]; then
# ntopng root
base_path="tools/localization"
root_path="."
elif [[ ! -d tools ]]; then
# inside localization folder
base_path="."
root_path="../../.."
fi
if [[ $# -lt 1 ]]; then
usage
fi
lang_path=
function get_lang_path {
if [[ -f "$root_path/pro/scripts/locales/${1}.lua" ]]; then
lang_path="$root_path/pro/scripts/locales/${1}.lua"
else
lang_path="$root_path/scripts/locales/${1}.lua"
fi
}
case $1 in
sort)
lang=$2
if [[ -z $lang ]]; then usage; fi
lua "$base_path/sort_localization_file.lua" "$lang"
;;
status)
lang=$2
if [[ -z $lang ]]; then usage; fi
get_lang_path "$lang"
"$base_path/missing_localization.py" cmp "$root_path/scripts/locales/en.lua" "$lang_path" | grep -v ".nedge."
;;
missing)
lang=$2
if [[ -z $lang ]]; then usage; fi
get_lang_path "$lang"
lua "$base_path/sort_localization_file.lua" "en"
lua "$base_path/sort_localization_file.lua" "$lang"
missing_lines=`"$base_path/missing_localization.py" missing "$root_path/scripts/locales/en.lua" "$lang_path"`
if [[ ! -z $missing_lines ]]; then
echo "*** REMOVE THE FOLLOWING LINES FROM ${lang}.lua BEFORE PROCEEDING ****" >&2
echo -e "$missing_lines" >&2
else
"$base_path/missing_localization.py" cmp "$root_path/scripts/locales/en.lua" "$lang_path" | grep -v ".nedge." | awk '{ $1=""; $2 = ""; print $0; }'
fi
;;
all)
lang=$2
if [[ -z $lang ]]; then usage; fi
get_lang_path "$lang"
"$base_path/missing_localization.py" cmp /dev/null "$lang_path" | grep -v ".nedge." | awk '{ $1=""; $2 = ""; print $0; }'
;;
extend)
lang=$2
extension_file=$3
if [[ -z $lang ]]; then usage; fi
if [[ -z $extension_file ]]; then usage; fi
lua "$base_path/sort_localization_file.lua" "$lang" "$extension_file"
;;
*) usage
esac