1 |
slords |
1.1 |
#!/usr/bash |
2 |
|
|
|
3 |
unnilennium |
1.8 |
strippo() { |
4 |
|
|
msgcat --sort-by-file --width 80 --to-code UTF-8 $1 \ |
5 |
|
|
| sed '/^"\(Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language\|Language-Team\|X-Generator\):/d;0,/^msgid/{/^#/d}' |
6 |
|
|
} |
7 |
|
|
|
8 |
|
|
podiff() { |
9 |
|
|
src=$1 |
10 |
|
|
dst=${2:-$(echo $1 | sed 's,/tmp/,/po/,')} |
11 |
|
|
|
12 |
|
|
if [ "${src%%.pot}" != "$src" -o "${src%%.po}" != "$src" ] |
13 |
|
|
then |
14 |
|
|
diff --unified --label "$src" <(strippo $src) --label "$dst" <(strippo $dst) |
15 |
|
|
elif [ "${src%%.tm}" != "$src" ] |
16 |
|
|
then |
17 |
|
|
diff --brief $src $dst > /dev/null |
18 |
|
|
else |
19 |
|
|
diff --unified $src $dst |
20 |
|
|
fi |
21 |
|
|
} |
22 |
|
|
|
23 |
slords |
1.1 |
diffmv() { |
24 |
|
|
if [ ! -z "$1" -a ! -z "$2" ] |
25 |
|
|
then |
26 |
slords |
1.4 |
if [ -f "$2" ] |
27 |
|
|
then |
28 |
unnilennium |
1.8 |
if podiff "$2" "$1" |
29 |
slords |
1.4 |
then |
30 |
unnilennium |
1.8 |
/bin/rm -f "$1" |
31 |
slords |
1.4 |
else |
32 |
unnilennium |
1.8 |
/bin/mv -f "$1" "$2" |
33 |
slords |
1.4 |
fi |
34 |
|
|
else |
35 |
|
|
/bin/mv -f "$1" "$2" |
36 |
|
|
fi |
37 |
slords |
1.1 |
fi |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
diffcp() { |
41 |
|
|
if [ ! -z "$1" -a ! -z "$2" ] |
42 |
|
|
then |
43 |
slords |
1.4 |
if [ -f "$2" ] |
44 |
|
|
then |
45 |
unnilennium |
1.8 |
if ! podiff "$2" "$1" |
46 |
slords |
1.4 |
then |
47 |
unnilennium |
1.8 |
/bin/cp -a "$1" "$2" |
48 |
slords |
1.4 |
fi |
49 |
|
|
else |
50 |
|
|
/bin/cp -a "$1" "$2" |
51 |
|
|
fi |
52 |
slords |
1.1 |
fi |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
potempl() { |
56 |
slords |
1.5 |
xgettext --from-code UTF-8 -L perl -o - $@ \ |
57 |
slords |
1.7 |
| sed 's@charset=CHARSET@charset=UTF-8@;s@[^ ]\+/\([^/]\+\)/[^/]\+/root/@\1/root/@g;s@Id-Version.*\\n@Id-Version: SME Template\\n@' \ |
58 |
slords |
1.1 |
| sed '/Report-Msgid-Bugs-To/d;/POT-Creation-Date/d;/PO-Revision-Date/d;/Language-Team/d;/X-Generator/d;0,/^msgid/{/^#/d}' \ |
59 |
|
|
| msgcat -F -t UTF-8 - |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
xmltempl() { |
63 |
slords |
1.7 |
mkdir -p /var/lib/pootle/templates/$1/ |
64 |
slords |
1.1 |
|
65 |
slords |
1.7 |
root=$(echo $2 | sed 's@.*/root/@root/@') |
66 |
|
|
cat $2 \ |
67 |
slords |
1.1 |
| perl -pe 's@<@_{_@g;s@>@_}_@g;s@&@_AMP_@g;s@_{_(/?(?:lexicon|entry|base|trans).*?)_}_@<$1>@g' \ |
68 |
|
|
| sed '/<\\\?lexicon/p;0,/<lexicon/d;/<\\lexicon/,$d' \ |
69 |
slords |
1.7 |
> /var/lib/pootle/tmp/$(basename $2).orig |
70 |
|
|
|
71 |
|
|
xml2po -m sme -e -o - /var/lib/pootle/tmp/$(basename $2).orig \ |
72 |
|
|
| sed "/(lexicon)/{N;N;N;d};s@[^ ]\+\(:[0-9]\+([^)]\+)\)@$1/$root\1@g" \ |
73 |
slords |
1.1 |
| tee >(cat - | sed '/^msgid/{p;s@msgid@msgstr@p;N;d}' \ |
74 |
slords |
1.7 |
| xml2po -m sme -p - /var/lib/pootle/tmp/$(basename $2).orig \ |
75 |
|
|
> /var/lib/pootle/tmp/$(basename $2) ) \ |
76 |
slords |
1.1 |
| perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \ |
77 |
|
|
| msgcat -F -t UTF-8 - \ |
78 |
slords |
1.7 |
| sed "/^\"POT-Creation-Date:/d;s@Id-Version.*\\\n@Id-Version: SME Template\\\n@" \ |
79 |
|
|
> /var/lib/pootle/tmp/$(basename $2).pot |
80 |
|
|
diffmv /var/lib/pootle/tmp/$(basename $2).orig /var/lib/pootle/templates/$1/$(basename $2).orig |
81 |
|
|
diffmv /var/lib/pootle/tmp/$(basename $2) /var/lib/pootle/templates/$1/$(basename $2) |
82 |
|
|
diffmv /var/lib/pootle/tmp/$(basename $2).pot /var/lib/pootle/templates/$1/$(basename $2).pot |
83 |
slords |
1.1 |
} |
84 |
|
|
|
85 |
|
|
anacondatmpl() { |
86 |
unnilennium |
1.8 |
content="" |
87 |
|
|
if [[ "$1" == "sme8" ]];then |
88 |
|
|
content="/var/lib/pootle/cvs/smeserver/cdrom.image/$1/updates/*.py /var/lib/pootle/cvs/smeserver/cdrom.image/$1/*/installclasses/*.py" |
89 |
|
|
fi |
90 |
slords |
1.1 |
xgettext -L python \ |
91 |
|
|
-k=_ \ |
92 |
|
|
-k=N_ \ |
93 |
|
|
-o - \ |
94 |
slords |
1.7 |
$(sed -n "/\.py/s@^\([^ \t]\+\)[ \t]\+\([^/]\+\)\(/.*\)\?@/var/lib/pootle/cvs/smeserver/\2/$1/\2-*\3/\1@p" \ |
95 |
|
|
/var/lib/pootle/cvs/smeserver/cdrom.image/$1/updates/README.txt) \ |
96 |
unnilennium |
1.8 |
$content \ |
97 |
|
|
2> /dev/null \ |
98 |
slords |
1.7 |
| sed 's@charset=CHARSET@charset=UTF-8@;s@Id-Version.*\\n@Id-Version: SME Template\\n@' \ |
99 |
|
|
| sed 's@/var/lib/pootle/cvs/smeserver/[^/]\+/@@' \ |
100 |
slords |
1.1 |
| msgcat -u \ |
101 |
|
|
--use-first \ |
102 |
|
|
- \ |
103 |
slords |
1.7 |
<(sed 's@CHARSET@UTF-8@' /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/anaconda.pot) \ |
104 |
|
|
<(sed 's@CHARSET@UTF-8@' /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/anaconda.pot) \ |
105 |
slords |
1.1 |
| sed '/Report-Msgid-Bugs-To/d;/POT-Creation-Date/d;/PO-Revision-Date/d;/Last-Translator/d;/Language-Team/d;/X-Generator/d;0,/^msgid/{/^#/d}' \ |
106 |
|
|
| msgcat -F -t UTF-8 - |
107 |
|
|
} |
108 |
|
|
|
109 |
|
|
xmltrans() { |
110 |
slords |
1.7 |
if [ ! -f /var/lib/pootle/templates/$1/$(basename $2) ] |
111 |
slords |
1.1 |
then |
112 |
slords |
1.7 |
echo "Missing /var/lib/pootle/templates/$1/$(basename $2)" |
113 |
|
|
elif [ ! -f /var/lib/pootle/templates/$1/$(basename $2).pot ] |
114 |
slords |
1.1 |
then |
115 |
slords |
1.7 |
echo "Missing /var/lib/pootle/templates/$1/$(basename $2).pot" |
116 |
slords |
1.1 |
else |
117 |
|
|
#| iconv -f ISO-8859-1 -t UTF-8 \ |
118 |
slords |
1.7 |
#lang=$(echo $2 | sed 's@.*/locale/\([^/]\+\)/.*@\1@') |
119 |
|
|
cat $2 \ |
120 |
slords |
1.1 |
| perl -pe 's@<@_{_@g;s@>@_}_@g;s@&@_AMP_@g;s@_{_(/?(?:lexicon|entry|base|trans).*?)_}_@<$1>@g' \ |
121 |
|
|
| sed '/<\\\?lexicon/p;0,/<lexicon/d;/<\\lexicon/,$d' \ |
122 |
slords |
1.7 |
| xml2po -m sme -r - -o - /var/lib/pootle/templates/$1/$(basename $2) \ |
123 |
slords |
1.1 |
| perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \ |
124 |
|
|
| sed "/(lexicon)/{N;N;N;d}" \ |
125 |
|
|
| msgcat -F -t UTF-8 - \ |
126 |
slords |
1.7 |
| msgmerge -q -F - /var/lib/pootle/templates/$1/$(basename $2).pot |
127 |
slords |
1.1 |
fi |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
xmlgen() { |
131 |
slords |
1.7 |
if [ ! -f /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@') ] |
132 |
slords |
1.1 |
then |
133 |
slords |
1.7 |
echo "Missing /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@')" 1>&2 |
134 |
slords |
1.1 |
else |
135 |
slords |
1.7 |
#lang=$(basename $(dirname $2)) |
136 |
|
|
msgcat -F $2 \ |
137 |
slords |
1.4 |
| perl -pe 's@<@_{_@g;s@>@_}_@g;s@&@_AMP_@g' \ |
138 |
|
|
| sed '/#,/d' | sed '1,/X-Generator/{;s,_{_,<,g;s,_}_,>,g;s,_AMP_,\&,g;}' \ |
139 |
slords |
1.1 |
| sed '/#,/d' \ |
140 |
slords |
1.7 |
| xml2po -m sme -p - /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@') \ |
141 |
slords |
1.1 |
| sed '1d' \ |
142 |
|
|
| perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \ |
143 |
|
|
| perl -pe 's@(lexicon\s+lang[^"]+"[^"]+)_([^"]+)"@"$1-".lc($2)."\""@e' |
144 |
|
|
fi |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
anacondagen() { |
148 |
slords |
1.7 |
if [ -f /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po ] |
149 |
slords |
1.1 |
then |
150 |
|
|
msgcat --use-first \ |
151 |
slords |
1.7 |
/var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po \ |
152 |
|
|
/var/lib/pootle/po/$1/$2/anaconda.po \ |
153 |
slords |
1.1 |
| msgfmt -f -o - - 2> /dev/null |
154 |
|
|
if [ $? -ne 0 ] |
155 |
|
|
then |
156 |
|
|
msgcat --use-first \ |
157 |
slords |
1.7 |
/var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po \ |
158 |
|
|
/var/lib/pootle/po/$1/$2/anaconda.po \ |
159 |
slords |
1.1 |
| msgfmt -o - - 2> /dev/null |
160 |
|
|
fi |
161 |
|
|
fi |
162 |
|
|
} |
163 |
|
|
|
164 |
|
|
localedir() { |
165 |
|
|
dir=$(echo $1 | perl -pe 's/_(.*)/-lc($1)/e') |
166 |
|
|
if [ "$2" == "general" ] |
167 |
|
|
then |
168 |
|
|
echo "root/etc/e-smith/locale/$dir/FormMagick" |
169 |
|
|
elif [ "$2" == "userpassword" ] |
170 |
|
|
then |
171 |
|
|
echo "root/etc/e-smith/locale/$dir/etc/e-smith/web/panels/password/cgi-bin" |
172 |
|
|
else |
173 |
|
|
echo "root/etc/e-smith/locale/$dir/etc/e-smith/web/functions" |
174 |
|
|
fi |
175 |
|
|
} |
176 |
|
|
|