forked from luxiaok/DNSmasqWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi18n
executable file
·51 lines (47 loc) · 1.41 KB
/
i18n
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
#!/bin/bash
langs_avail=`ls -1 translations`
## Update the babel translation
usage () {
echo "Update the internationalisation."
echo "Usage: $0 (update|edit|commit) ([lang]|all)*"
echo " todo - find non-ascii characters outside translation files"
echo " update - gets new var from source and updates messages.pot"
echo " edit - edits each translations/..../*.po with ${EDITOR}"
echo " commit - reads messages.pot and outputs translations/..../*.po"
echo "[lang] - specify the language to manipulate, one of:"
echo " ${langs_avail[@]}"
echo "Specifying no language defaults to \"all\"."
exit 1
}
if [ $# -gt 2 ] || [ $# -lt 1 ]; then
usage
elif [ $# -eq 1 ] || [ $2 == 'all' ]; then
declare -a langs
langs=$langs_avail
else
declare -a langs
langs=( $2 )
fi
ACTION="$1"
case $ACTION in
todo)
grep -I -r --exclude=README.md --exclude-dir=translations --exclude-dir=.git --color='auto' -P -n '[^\x00-\x7F]' ./
;;
update)
pybabel extract -F babel.cfg -k lazy_gettext -o messages.pot .
pybabel update -i messages.pot -d translations
;;
edit)
editor="${VISUAL:-vi}"
for lang in ${langs[@]}; do
${editor} "translations/${lang}/LC_MESSAGES/messages.po"
done
;;
commit)
pybabel compile -d translations
;;
*)
echo "Unknown action $ACTION"
exit 1
;;
esac