51c3e88c89c4acc15161aedd5f3b5813ffb2983c
[goodguy/history.git] / cinelerra-5.1 / po / xlat.sh
1 #!/bin/bash
2 # this script is used on c++ source to modify the _()
3 #  gettext calls to use msgqual(ctxt,id) instead.
4 # local context regions are defined by using:
5 #
6 # #undef MSGQUAL
7 # #define MSGQUAL "qual_id"
8 # ... code with _() ...
9 # #undef MSGQUAL
10 # #define MSGQUAL 0
11 #
12
13 cin_dir=`mktemp -d -p /tmp cin_XXXXXX`
14 trap "rm -rf '$cin_dir'" EXIT
15 mkdir -p "$cin_dir"
16
17 echo 1>&2 "edit"
18 for d in guicast cinelerra plugins/*; do
19   if [ ! -d "$d" ]; then continue; fi
20   mkdir -p "$cin_dir/$d"
21   ls -1 "$d"/*.[Ch] "$d"/*.inc 2> /dev/null
22 done | while read f ; do
23 #qualifier is reset using #define MSGQUAL "qual_id"
24 #this changes:
25 #   code C_("xxx") [... code _("yyy")]
26 #to:
27 #   code D_("qual_id#xxx") [... code D_("qual_id#yyy")]
28   sed -n "$f" > "$cin_dir/$f" -f - <<<'1,1{x; s/.*/_("/; x}
29 :n1 s/^\(#define MSGQUAL[       ]\)/\1/; t n4
30 :n2 s/\<C_("/\
31 /; t n3; P; d; n; b n1
32 :n3 G; s/^\(.*\)\
33 \(.*\)\
34 \(.*\)$/\1\3\2/; b n2
35 :n4 p; s/^#define MSGQUAL[       ]*"\(.*\)"$/D_("\1#/; t n5
36 s/^.*$/_("/; h; d; n; b n1
37 :n5 h; d; n; b n1
38 '
39 done
40
41 #scan src and generate cin.po
42 echo 1>&2 "scan"
43 cd "$cin_dir"
44 for d in guicast cinelerra plugins/*; do
45   if [ ! -d "$d" ]; then continue; fi
46   ls -1 $d/*.[Ch] $d/*.inc 2> /dev/null
47 done | xgettext --no-wrap -L C++ -k_ -kN_ -kD_ -f - -o -
48
49 echo 1>&2 "done"
50