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