Reference manual: Fix user's manual generation
[nautilus-actions.git] / tools / check-po.sh
blob030fab36dd35c0db15570fe06e272378dfad1636
1 #!/bin/sh
3 # a small script to check the completeness of po/POTFILES.in
5 # should be ran from top_srcdir
7 PO=po/POTFILES.in
8 if [ ! -r ${PO} ]; then
9 echo "${PO}: file not found" 1>&2
10 echo "This script should be ran from top_srcdir." 1>&2
11 exit 1
14 # first, check that all .ui are in po/POTFILE.in
16 total=0
17 count=0
18 errs=0
19 echo ""
20 echo "checking that all .ui are in ${PO}..."
21 for f in $(find src -name '*.ui' | sed 's?^\./??'); do
22 if [ "$(grep -x ${f} ${PO})" != "${f}" ]; then
23 echo " ${f} should be added to ${PO}"
24 let errs+=1
26 let count+=1
27 done
28 echo "pass 1/5: count=${count} error(s)=${errs}"
29 let total+=${errs}
31 # second, check that all .ui in PO exist
33 count=0
34 errs=0
35 echo ""
36 echo "checking that all .ui from ${PO} actually exist..."
37 for f in $(grep -E '\.ui$' ${PO}); do
38 if [ ! -r ${f} ]; then
39 echo " ${f} should be removed from ${PO}"
40 let errs+=1
42 let count+=1
43 done
44 echo "pass 2/5: count=${count} error(s)=${errs}"
45 let total+=${errs}
47 # third, check that all files which use _( construct are in PO
49 count=0
50 errs=0
51 echo ""
52 echo "checking that all translatable files are in ${PO}..."
53 exceptions_pass3="src/test/check-po.sh"
54 for f in $(git grep '_(' src | cut -d: -f1 | sort -u); do
55 if [ "$(echo ${exceptions_pass3} | grep -w ${f})" = "" ]; then
56 if [ "$(grep -x ${f} ${PO})" != "${f}" ]; then
57 echo " ${f} should be added to ${PO}"
58 let errs+=1
61 let count+=1
62 done
63 echo "pass 3/5: count=${count} error(s)=${errs}"
64 let total+=${errs}
66 # fourth, check that all files in PO actually use the _( construct
68 count=0
69 errs=0
70 echo ""
71 echo "checking that all files in ${PO} actually use the '_(' construct..."
72 for f in $(grep -E '^src/' ${PO} | grep -vE '\.ui$' | grep -vE '\.in$'); do
73 grep '_(' ${f} 1>/dev/null 2>&1
74 if [ $? -ne 0 ]; then
75 echo " ${f} should be removed from ${PO}"
76 let errs+=1
78 let count+=1
79 done
80 echo "pass 4/5: count=${count} error(s)=${errs}"
81 let total+=${errs}
83 # last, check that all files which include gi18n.h are relevant
85 count=0
86 errs=0
87 echo ""
88 echo "checking that all files have a good reason to include gi18n.h..."
89 for f in $(git grep '#include <glib/gi18n.h>' src | cut -d: -f1 | sort -u); do
90 grep '_(' ${f} 1>/dev/null 2>&1
91 if [ $? -ne 0 ]; then
92 echo " ${f} should not include <glib/gi18n.h>"
93 let errs+=1
95 let count+=1
96 done
97 echo "pass 5/5: count=${count} error(s)=${errs}"
98 let total+=${errs}
100 echo ""
101 echo "total: ${total} error(s)."