]> git.deb.at Git - deb/packages.git/blob - cron.d/500update_po
Merge branch 'master' of ssh://spaillar-guest@git.debian.org/git/webwml/packages
[deb/packages.git] / cron.d / 500update_po
1 #! /bin/bash
2
3 . `dirname $0`/../config.sh
4
5 cd "$topdir"
6 gettextfiles="
7 lib/Packages/CGI.pm
8 lib/Packages/Config.pm
9 lib/Packages/DB.pm
10 lib/Packages/DoDownload.pm
11 lib/Packages/DoFilelist.pm
12 lib/Packages/DoIndex.pm
13 lib/Packages/DoNewPkg.pm
14 lib/Packages/DoSearch.pm
15 lib/Packages/DoSearchContents.pm
16 lib/Packages/DoShow.pm
17 lib/Packages/Page.pm
18 lib/Packages/Search.pm
19 lib/Packages/SrcPage.pm
20 lib/Packages/Template.pm
21 lib/Packages/Dispatcher.pm
22 bin/create_index_pages
23 "
24 templatefiles="
25 templates/config.tmpl
26 templates/config/architectures.tmpl
27 templates/config/archive_layout.tmpl
28 templates/config/mirrors.tmpl
29 templates/html/download.tmpl
30 templates/html/error.tmpl
31 templates/html/filelist.tmpl
32 templates/html/foot.tmpl
33 templates/html/head.tmpl
34 templates/html/index_head.tmpl
35 templates/html/index_foot.tmpl
36 templates/html/messages.tmpl
37 templates/html/newpkg.tmpl
38 templates/html/search.tmpl
39 templates/html/search_contents.tmpl
40 templates/html/show.tmpl
41 templates/html/suite_index.tmpl
42 templates/html/tag_index.tmpl
43 templates/html/util.inc
44 templates/rfc822/search.tmpl
45 templates/rss/newpkg.tmpl
46 templates/txt/index_head.tmpl
47 templates/txt/index_foot.tmpl
48 "
49 podomains="pdo templates sections langs debtags"
50
51 # Update pot
52 #
53 # Common options for all calls
54 xgettext_opts="--language=Perl --keyword=N_ --keyword=g --foreign-user --add-comments"
55
56 echo gettextfiles=$gettextfiles
57 echo templatefiles=$templatefiles
58 xgettext $xgettext_opts -d pdo -o ${podir}/pdo.pot.new ${gettextfiles}
59 xgettext $xgettext_opts -d sections -o ${podir}/sections.pot.new ${libdir}/Packages/Sections.pm
60 xgettext $xgettext_opts -d langs -o ${podir}/langs.pot.new ${libdir}/Packages/I18N/LanguageNames.pm
61 $topdir/bin/ttxgettext templates ${templatefiles} >${podir}/templates.pot.new
62 if [ -f files/debtags/vocabulary ]; then
63     $topdir/bin/debtags-xgettext files/debtags/vocabulary >${podir}/debtags.pot.new
64 fi
65
66 cd $podir
67
68 # Create missing po files
69 #
70 for lang in ${polangs}
71 do
72   for domain in ${podomains}
73   do
74     test -f ${domain}.${lang}.po || cp ${domain}.pot ${domain}.${lang}.po
75   done
76 done
77
78 # normalize paths in .pot files
79 for domain in ${podomains}
80 do
81   perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.pot.new
82   if [ ! -f ${domain}.pot.new ] || diff -I"POT-Creation-Date" -q ${domain}.pot.new ${domain}.pot >/dev/null 2>&1
83   then
84       echo "${domain}.pot unchanged"
85       rm ${domain}.pot.new
86   else
87       echo "${domain}.pot changed"
88       mv ${domain}.pot.new ${domain}.pot
89       # Update po
90       for lang in ${polangs} 
91       do
92         echo "  update ${domain}.${lang}.po"
93         cp ${domain}.${lang}.po ${domain}.${lang}.po.tmp
94         msgmerge --previous --quiet --sort-by-file -o ${domain}.${lang}.po ${domain}.${lang}.po.tmp ${domain}.pot
95         rm ${domain}.${lang}.po.tmp
96         # normalize paths in .po files
97         perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.${lang}.po
98       done
99   fi
100 done
101
102 # print statistics
103 for lang in ${polangs}
104 do
105   echo
106   echo "Statistics about $lang:"
107   for po in *.${lang}.po
108   do
109     echo $po:
110     LANG=C msgfmt --statistics --check-format -o- $po >/dev/null
111   done
112 done