]> git.deb.at Git - deb/packages.git/blob - cron.d/500update_mo
Translation support for remaining scripts
[deb/packages.git] / cron.d / 500update_mo
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.tmpl
35 templates/html/menu.inc
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/rfc822/search.tmpl
44 templates/rss/newpkg.tmpl
45 templates/txt/index.tmpl
46 "
47 podomains="pdo templates sections langs debtags"
48
49 # Update pot
50 #
51 # Common options for all calls
52 xgettext_opts="--language=Perl --keyword=N_ --keyword=g --foreign-user --add-comments"
53
54 echo gettextfiles=$gettextfiles
55 echo templatefiles=$templatefiles
56 xgettext $xgettext_opts -d pdo -o ${podir}/pdo.pot.new ${gettextfiles}
57 xgettext $xgettext_opts -d sections -o ${podir}/sections.pot.new ${libdir}/Packages/Sections.pm
58 xgettext $xgettext_opts -d langs -o ${podir}/langs.pot.new ${libdir}/Packages/I18N/LanguageNames.pm
59 $topdir/bin/ttxgettext templates ${templatefiles} >${podir}/templates.pot.new
60 if [ -f files/debtags/vocabulary ]; then
61     $topdir/bin/debtags-xgettext files/debtags/vocabulary >${podir}/debtags.pot.new
62 fi
63
64 cd $podir
65
66 # Create missing po files
67 #
68 for lang in ${polangs}
69 do
70   for domain in ${podomains}
71   do
72     test -f ${domain}.${lang}.po || cp ${domain}.pot ${domain}.${lang}.po
73   done
74 done
75
76 # normalize paths in .pot files
77 for domain in ${podomains}
78 do
79   perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.pot.new
80   if [ ! -f ${domain}.pot.new ] || diff -I"POT-Creation-Date" -q ${domain}.pot.new ${domain}.pot >/dev/null 2>&1
81   then
82       echo "${domain}.pot unchanged"
83       rm ${domain}.pot.new
84   else
85       echo "${domain}.pot changed"
86       mv ${domain}.pot.new ${domain}.pot
87       # Update po
88       for lang in ${polangs} 
89       do
90         echo "  update ${domain}.${lang}.po"
91         cp ${domain}.${lang}.po ${domain}.${lang}.po.tmp
92         msgmerge --previous --quiet --sort-by-file -o ${domain}.${lang}.po ${domain}.${lang}.po.tmp ${domain}.pot
93         rm ${domain}.${lang}.po.tmp
94         # normalize paths in .po files
95         perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.${lang}.po
96       done
97   fi
98 done
99
100 echo
101 # Update mo
102 #
103 test -d ${localedir} || mkdir -p ${localedir}
104 for lang in ${polangs}
105 do 
106   test -d ${localedir}/${lang}/LC_MESSAGES \
107       || mkdir -p ${localedir}/${lang}/LC_MESSAGES
108   for domain in ${podomains}
109   do
110     echo domain=$domain language=$lang
111     msgfmt --statistics -o ${localedir}/${lang}/LC_MESSAGES/${domain}.mo ${domain}.${lang}.po
112   done
113 done