rework intl strategy, titler upgrades, fonts fixes, igor ru.po
[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 if [ $# -lt 1 -o ! -d "$1" ]; then
13   echo 1>&2 "usage: $0 /<path>/cinelerra-src [/tmp] > /<path>/cin.po"
14   exit 1
15 fi
16
17 cin_dir=`basename "$1"`
18 tmp_dir=`mktemp -d -p ${2:-/tmp} cin_XXXXXX`
19 trap "rm -rf '$tmp_dir'" EXIT
20
21 #need a copy of src dir for editing
22 echo 1>&2 "copy"
23 cp -a "$1" "$tmp_dir/."
24 cd "$tmp_dir/$cin_dir"
25
26 echo 1>&2 "edit"
27 for d in guicast/ cinelerra/ plugins/*; do
28   if [ ! -d "$d" ]; then continue; fi
29   ls -1 $d/*.[Ch] $d/*.inc 2> /dev/null
30 done | while read f ; do
31 #qualifier is reset using #define MSGQUAL "qual_id"
32 #this changes:
33 #   code C_("xxx") [... code _("yyy")]
34 #to:
35 #   code D_("qual_id#xxx") [... code D_("qual_id#yyy")]
36   sed -n -i "$f" -f - <<<'1,1{x; s/.*/_("/; x}
37 :n1 s/^\(#define MSGQUAL[       ]\)/\1/; t n4
38 :n2 s/\<C_("/\
39 /; t n3; P; d; n; b n1
40 :n3 G; s/^\(.*\)\
41 \(.*\)\
42 \(.*\)$/\1\3\2/; b n2
43 :n4 p; s/^#define MSGQUAL[       ]*"\(.*\)"$/D_("\1#/; t n5
44 s/^.*$/_("/; h; d; n; b n1
45 :n5 h; d; n; b n1
46 '
47 done
48
49 #scan src and generate cin.po
50 echo 1>&2 "scan"
51 for d in guicast/ cinelerra/ plugins/*; do
52   if [ ! -d "$d" ]; then continue; fi
53   ls -1 $d/*.[Ch] $d/*.inc 2> /dev/null
54 done | xgettext --no-wrap -L C++ -k_ -kN_ -kD_ -f - -o -
55
56 echo 1>&2 "done"
57