/[smeserver]/builds_bin/functions
ViewVC logotype

Contents of /builds_bin/functions

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download)
Tue Mar 14 22:24:56 2017 UTC (7 years, 8 months ago) by unnilennium
Branch: MAIN
Changes since 1.7: +31 -25 lines
updated functions support SME9 and many other features added before me since 2010

1 #!/usr/bash
2
3 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 diffmv() {
24 if [ ! -z "$1" -a ! -z "$2" ]
25 then
26 if [ -f "$2" ]
27 then
28 if podiff "$2" "$1"
29 then
30 /bin/rm -f "$1"
31 else
32 /bin/mv -f "$1" "$2"
33 fi
34 else
35 /bin/mv -f "$1" "$2"
36 fi
37 fi
38 }
39
40 diffcp() {
41 if [ ! -z "$1" -a ! -z "$2" ]
42 then
43 if [ -f "$2" ]
44 then
45 if ! podiff "$2" "$1"
46 then
47 /bin/cp -a "$1" "$2"
48 fi
49 else
50 /bin/cp -a "$1" "$2"
51 fi
52 fi
53 }
54
55 potempl() {
56 xgettext --from-code UTF-8 -L perl -o - $@ \
57 | sed 's@charset=CHARSET@charset=UTF-8@;s@[^ ]\+/\([^/]\+\)/[^/]\+/root/@\1/root/@g;s@Id-Version.*\\n@Id-Version: SME Template\\n@' \
58 | 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 mkdir -p /var/lib/pootle/templates/$1/
64
65 root=$(echo $2 | sed 's@.*/root/@root/@')
66 cat $2 \
67 | 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 > /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 | tee >(cat - | sed '/^msgid/{p;s@msgid@msgstr@p;N;d}' \
74 | xml2po -m sme -p - /var/lib/pootle/tmp/$(basename $2).orig \
75 > /var/lib/pootle/tmp/$(basename $2) ) \
76 | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \
77 | msgcat -F -t UTF-8 - \
78 | 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 }
84
85 anacondatmpl() {
86 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 xgettext -L python \
91 -k=_ \
92 -k=N_ \
93 -o - \
94 $(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 $content \
97 2> /dev/null \
98 | 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 | msgcat -u \
101 --use-first \
102 - \
103 <(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 | 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 if [ ! -f /var/lib/pootle/templates/$1/$(basename $2) ]
111 then
112 echo "Missing /var/lib/pootle/templates/$1/$(basename $2)"
113 elif [ ! -f /var/lib/pootle/templates/$1/$(basename $2).pot ]
114 then
115 echo "Missing /var/lib/pootle/templates/$1/$(basename $2).pot"
116 else
117 #| iconv -f ISO-8859-1 -t UTF-8 \
118 #lang=$(echo $2 | sed 's@.*/locale/\([^/]\+\)/.*@\1@')
119 cat $2 \
120 | 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 | xml2po -m sme -r - -o - /var/lib/pootle/templates/$1/$(basename $2) \
123 | perl -pe 's@_AMP_@&@g;s@_{_@<@g;s@_}_@>@g' \
124 | sed "/(lexicon)/{N;N;N;d}" \
125 | msgcat -F -t UTF-8 - \
126 | msgmerge -q -F - /var/lib/pootle/templates/$1/$(basename $2).pot
127 fi
128 }
129
130 xmlgen() {
131 if [ ! -f /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@') ]
132 then
133 echo "Missing /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@')" 1>&2
134 else
135 #lang=$(basename $(dirname $2))
136 msgcat -F $2 \
137 | perl -pe 's@<@_{_@g;s@>@_}_@g;s@&@_AMP_@g' \
138 | sed '/#,/d' | sed '1,/X-Generator/{;s,_{_,<,g;s,_}_,>,g;s,_AMP_,\&,g;}' \
139 | sed '/#,/d' \
140 | xml2po -m sme -p - /var/lib/pootle/templates/$1/$(basename $2 | sed 's@\.pot\?$@@') \
141 | 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 if [ -f /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po ]
149 then
150 msgcat --use-first \
151 /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po \
152 /var/lib/pootle/po/$1/$2/anaconda.po \
153 | msgfmt -f -o - - 2> /dev/null
154 if [ $? -ne 0 ]
155 then
156 msgcat --use-first \
157 /var/lib/pootle/cvs/smeserver/anaconda/$1/anaconda-*/po/$2.po \
158 /var/lib/pootle/po/$1/$2/anaconda.po \
159 | 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

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed