-
Notifications
You must be signed in to change notification settings - Fork 370
/
i18n.sh
executable file
·118 lines (106 loc) · 3.24 KB
/
i18n.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
function usage () {
echo "usage: $0 <options>"
echo
echo " update <app> update po of this app"
echo " update seahub update po of seahub"
echo " update-all update po of all apps"
echo " compile <app> compile po file of this app"
echo " compile seahub compile po file of seahub"
echo " compile-all compile po files of all apps"
echo
}
apps="seahub/trusted_ip"
function is_valid_app() {
if [[ $1 == "seahub" ]]; then
return 0;
fi
for app in ${apps}; do
if [[ $1 == $app ]]; then
return 0;
fi
done
return 1
}
# On some systems django-admin.py is only django-admin
if which django-admin.py 2>/dev/null 1>&2; then
django_admin=django-admin.py
elif which django-admin 2>/dev/null 1>&2; then
django_admin=django-admin
else
echo "ERROR: django-admin script not found"
exit 1
fi
# check args
if [[ $# == 0 ]]; then
usage;
exit 1;
fi
if [[ $1 == "-h" || $1 == "--help" || $1 == "help" ]]; then
usage;
exit 0;
fi
if [[ $1 != "update" && $1 != "update-all" && $1 != "compile" && $1 != "compile-all" ]]; then
usage;
exit 1;
fi
if [[ $1 == "update" || $1 == "compile" ]]; then
if [[ $# != 2 ]]; then
usage;
exit 1;
fi
if ! is_valid_app $2; then
echo "\"$2\" is not a valid app name";
exit 1
fi
fi
case $1 in
update)
printf "\033[1;32m[i18n]\033[m >>>>> update po of $2 <<<<<\n"
if [[ $2 == "seahub" ]]; then
${django_admin} makemessages -l zh_CN -e py,html \
-i "thirdpart*" -i "api*" -i "avatar*" -i "base*" \
-i "contacts*" -i "group*" -i "notifications*" -i "organizations*" \
-i "profile*" -i "share*" -i "media*"
else
pushd $2 2>/dev/null 1>&2
${django_admin} makemessages -l zh_CN -e py,html
popd 2>/dev/null 1>&2
fi
;;
update-all)
printf "\033[1;32m[i18n]\033[m >>>>> update po of seahub <<<<<\n"
${django_admin} makemessages -l zh_CN -e py,html \
-i "thirdpart*" -i "api*" -i "avatar*" -i "base*" \
-i "contacts*" -i "group*" -i "notifications*" -i "organizations*" \
-i "profile*" -i "share*" -i "media*"
for app in ${apps}; do
printf "\033[1;32m[i18n]\033[m >>>>> update po of ${app} <<<<<\n"
pushd ${app} 2>/dev/null 1>&2
${django_admin} makemessages -l zh_CN -e py,html
popd 2>/dev/null 1>&2
done
;;
compile)
printf "\033[1;32m[i18n]\033[m >>>>> compile po of $2 <<<<<\n"
if [[ $2 == "seahub" ]]; then
${django_admin} compilemessages
else
pushd $2
${django_admin} compilemessages
popd
fi
;;
compile-all)
printf "\033[1;32m[i18n]\033[m >>>>> compile po of seahub <<<<<\n"
${django_admin} compilemessages
for app in ${apps}; do
printf "\033[1;32m[i18n]\033[m >>>>> compile po of ${app} <<<<<\n"
pushd ${app} 2>/dev/null 1>&2
${django_admin} compilemessages
popd
done
;;
esac
echo Done
echo