From: Frank Lichtenheld Date: Sat, 20 Oct 2007 19:24:08 +0000 (+0200) Subject: 500update_mo: Only update .po and .pot files if needed X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=3cb141cbaf6a29c81ea464e555df33eaa8a75eec;p=deb%2Fpackages.git 500update_mo: Only update .po and .pot files if needed Don't create unneccessary diffs. --- diff --git a/cron.d/500update_mo b/cron.d/500update_mo index 073e842..3b5c844 100755 --- a/cron.d/500update_mo +++ b/cron.d/500update_mo @@ -53,19 +53,13 @@ xgettext_opts="--language=Perl --keyword=N_ --keyword=_g --foreign-user --add-co echo gettextfiles=$gettextfiles echo templatefiles=$templatefiles -xgettext $xgettext_opts -d pdo -o ${podir}/pdo.pot ${gettextfiles} -$topdir/bin/ttxgettext templates ${templatefiles} >${podir}/templates.pot -xgettext $xgettext_opts -d sections -o ${podir}/sections.pot ${libdir}/Packages/Sections.pm -xgettext $xgettext_opts -d langs -o ${podir}/langs.pot ${libdir}/Packages/I18N/LanguageNames.pm +xgettext $xgettext_opts -d pdo -o ${podir}/pdo.pot.new ${gettextfiles} +$topdir/bin/ttxgettext templates ${templatefiles} >${podir}/templates.pot.new +xgettext $xgettext_opts -d sections -o ${podir}/sections.pot.new ${libdir}/Packages/Sections.pm +xgettext $xgettext_opts -d langs -o ${podir}/langs.pot.new ${libdir}/Packages/I18N/LanguageNames.pm cd $podir -# normalize paths in .pot files -for domain in ${podomains} -do - perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.pot -done - # Create missing po files # for lang in ${polangs} @@ -76,20 +70,31 @@ do done done -# Update po -# -for lang in ${polangs} +# normalize paths in .pot files +for domain in ${podomains} do - for domain in ${podomains} - do - cp ${domain}.${lang}.po ${domain}.${lang}.po.tmp - msgmerge --previous --quiet --sort-by-file -o ${domain}.${lang}.po ${domain}.${lang}.po.tmp ${domain}.pot - rm ${domain}.${lang}.po.tmp - # normalize paths in .po files - perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.${lang}.po - done + perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.pot.new + if diff -I"POT-Creation-Date" -q ${domain}.pot.new ${domain}.pot >/dev/null 2>&1 + then + echo "${domain}.pot unchanged" + rm ${domain}.pot.new + else + echo "${domain}.pot changed" + mv ${domain}.pot.new ${domain}.pot + # Update po + for lang in ${polangs} + do + echo " update ${domain}.${lang}.po" + cp ${domain}.${lang}.po ${domain}.${lang}.po.tmp + msgmerge --previous --quiet --sort-by-file -o ${domain}.${lang}.po ${domain}.${lang}.po.tmp ${domain}.pot + rm ${domain}.${lang}.po.tmp + # normalize paths in .po files + perl -p -i -e "s,^#:\s*\Q${topdir}\E,#: .,go" ${domain}.${lang}.po + done + fi done +echo # Update mo # test -d ${localedir} || mkdir -p ${localedir}