]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - locale/update-makefile.sh
Fix French translation
[SourceForge/phpwiki.git] / locale / update-makefile.sh
1 #!/bin/sh
2 #
3 # $Id$
4 #
5 # This shell script is used to update the list of .po files and the
6 # dependencies for phpwiki.pot in the Makefile.
7 #
8 # Do not invoke this script directly, rather run:
9 #
10 #    make depend
11 #
12 # to update the Makefile.
13 #
14
15 # Generate the head (manually-edited part) of the new Makefile
16 #
17 makefile_head () {
18     sed '/^# DO NOT DELETE THIS LINE$/,$ d' Makefile && cat <<'EOF'
19 # DO NOT DELETE THIS LINE
20 #
21 # The remainder of this file is auto-generated
22 #
23 # (Run 'make depend' regenerate this section.)
24 #
25 EOF
26 }
27
28 # Find all .po files in po/.
29 #
30 po_files () {
31     find po -name "*.po" |
32         sort |
33         sed 's/^/po: /p;
34              s|^.*/\(.*\)\.po$|mo: \1/LC_MESSAGES/phpwiki.mo \1/LC_MESSAGES/phpwiki.php|;'
35 }
36
37 # Find all php and html source code which should be scanned
38 # by xgettext() for localizeable strings.
39 # find ../lib fails on cygwin
40 # TODO: autogenerate .exclude list from CVS/Entries
41 pot_file_deps () {
42     test -f .exclude || ( echo lib/pear/ > .exclude; echo lib/WikiDB/adodb/ > .exclude; echo lib/nusoap/ > .exclude )
43     (cd ..; find lib themes \( -type d -regex '\(^lib/pear\)\|\(^lib/WikiDB/adodb\)\|\(^lib/nusoap\)\|\(^lib/fpdf\)' \) -prune -o \( -type f -a -name \*.php -o -name \*.tmpl \)) |
44         egrep -v '(^lib/pear)|(^lib/WikiDB/adodb)|(^lib/nusoap)|(^lib/fpdf)' |
45         grep -v -f .exclude |
46         sed 's|^|${POT_FILE}: ../|;' |
47         sort
48 }
49
50 # Generate the new Makefile
51 { makefile_head &&
52     po_files &&
53     echo "#" &&
54     pot_file_deps; } > Makefile.new || exit 1
55
56 if diff -q Makefile Makefile.new > /dev/null
57 then
58     # Don't touch the Makefile if unchanged.
59     # (This avoids updating the timestamp)
60     rm Makefile.new
61     echo "Makefile unchanged" 1>&2
62     exit 0
63 fi
64
65 mv Makefile.new Makefile && echo "Makefile updated" 1>&2