-
Notifications
You must be signed in to change notification settings - Fork 47
/
desc-link.sh
executable file
·110 lines (94 loc) · 2.28 KB
/
desc-link.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
#!/bin/sh
# support translators to check their module.info.lang files
# and decide if they can linked to existing webadmin version
[ "$EDITOR" == "" ] && EDITOR=vi
FORCE=""
WEBMIN="../webmin"
[ -d "../webadmin" ] && WEBMIN="../webadmin"
if [ ! -d $WEBMIN ]
then
echo "webmin not found! please check out webmin from github."
exit 1
fi
# help
if [ "$1" == "-h" ]
then
cat <<EOF
usage: $0 [-force] LANG
this script helps translators to find out if descriptions
for a given language already exsits in webmin and offers to:
link same description is used for webmin and usermin
edit edit description in webmin to fit both
parameters:
force
link all found possibilities
LANG
language code to process, e.g. $LANG
how to:
- checkout usermin and webmin from github:
# git clone https://github.com/<YOURNAME>/webmin.git webadmin
# git clone https://github.com/<YOURNAME>/usermin.git
- cd to usermin and run script
# cd usermin; $0 de
- push changes to repository
# git add; git commit -m "LANG xx"
# git push
EOF
echo "availible languages:"
( cd $WEBMIN/lang; ls )
exit
fi
# check for force
if [ "$1" == "-force" ]
then
FORCE="yes"
shift
fi
# $1 is LAMNG to check
if [ "$1" == "" ]
then
echo "error: missing parameter!"
echo "usage: $0 LANG"
echo " where LANG is the langcode to check, e.g. de de no fr"
exit 1
fi
LANG=$1
#get lang files
for module in `ls */module.info 2>/dev/null`
do
file="$module.$LANG"
# skip if wbebmin/file not exsit ort already symlinked
[ ! -f "$WEBMIN/$file" -o -h "$file" ] && continue
echo -e "\nprocessing file -> $file\n--------------------"
if [ ! -f "$file" ]
then
echo " -> missing translation for \"$LANG\" found!"
else
cat $file
fi
echo -e "\nwebmin file -> $WEBMIN/$file \n--------------------"
cat ../webadmin/$file
echo -n -e "\nselect action: [e]dit webmin file, [l]ink, [S]kip ?\b"
if [ "$FORCE" == "" ]
then
read ans
fi
if [ "$ans" == "l" -o "$FORCE" != "" ]
then
echo "linking $file -> $WEBMIN/$file"
[ -f "$file" ] && mv $file $file.sav
ln -s ../webadmin/$file $file
if [ $? -ne 0 ]; then
[ -f "$file.sav" ] && mv $file.sav $file
echo "linking failed!"
else
echo -e "done!\n"
rm -f $file.sav
fi
fi
if [ "$ans" == "e" ]
then
echo "editing $WEBMIN/$file"
${EDITOR} $WEBMIN/$file
fi
done