translation-update-upstream/msgheadermerge
Stanislav Brabec 6fa3b3cab0 Accepting request 149833 from home:sbrabec:branches:Base:System
Tarball update plus supplementary scripts change:
- Supplementary scripts improvements:
  * Validate all imported po files before merge.
  * Try harder to make plural forms consistent.
  * Collect full translations of all projects.
  * Create a domain map.
  * Added a script that makes possible to prepare translations for
    post-install translation-update package.
  * Support for pending translation fixes.
  * "static" method for update from attached tarball
    (needed if upstream disappeared)

OBS-URL: https://build.opensuse.org/request/show/149833
OBS-URL: https://build.opensuse.org/package/show/Base:System/translation-update-upstream?expand=0&rev=46
2013-01-24 19:39:58 +00:00

60 lines
2.4 KiB
Bash

#!/bin/bash
# msgheadermerge expected_older.po expected_newer.po dest-header.po [--mergemode|--newdate|]
# This tool merges headers of two .po files and never loses extra info (e. g. plurals).
rm -rf {${1%.po},${2%.po}}-msgheadermerge-temp.{merge-dir,order}
trap "rm -rf {${1%.po},${2%.po}}-msgheadermerge-temp.{merge-dir,order} ${2%.po}-msgheadermerge-tempheader{,1}.po" 0
RC=0
# Broken pipe is an expected behavior. Redirect stderr to /dev/null.
msgexec -i $1 $0-parse ${1%.po}-msgheadermerge-temp 2>/dev/null
msgexec -i $2 $0-parse ${2%.po}-msgheadermerge-temp 2>/dev/null
# If --swap-plural-forms was used, use plural definition from the other header.
if test "$6" = --old-plural-forms ; then
if test -f ${1%.po}-msgheadermerge-temp.merge-dir/Plural-Forms ; then
if test -f ${2%.po}-msgheadermerge-temp.merge-dir/Plural-Forms ; then
rm ${2%.po}-msgheadermerge-temp.merge-dir/POT-Creation-Date
fi
fi
fi
# Keep original POT date with --mergemode and fail for outdated PO:
if test "$4" = --mergemode ; then
rm ${2%.po}-msgheadermerge-temp.merge-dir/POT-Creation-Date
if test ${2%.po}-msgheadermerge-temp.merge-dir/PO-Revision-Date -ot ${1%.po}-msgheadermerge-temp.merge-dir/PO-Revision-Date ; then
if test "$5" = --continue ; then
RC=1
else
exit 1
fi
fi
else
if test "$4" = --newdate ; then
rm ${1%.po}-msgheadermerge-temp.merge-dir/PO-Revision-Date
rm ${1%.po}-msgheadermerge-temp.merge-dir/POT-Creation-Date
else
if test ${2%.po}-msgheadermerge-temp.merge-dir/POT-Creation-Date -ot ${1%.po}-msgheadermerge-temp.merge-dir/POT-Creation-Date ; then
rm ${2%.po}-msgheadermerge-temp.merge-dir/POT-Creation-Date
fi
if test ${2%.po}-msgheadermerge-temp.merge-dir/PO-Revision-Date -ot ${1%.po}-msgheadermerge-temp.merge-dir/PO-Revision-Date ; then
rm ${2%.po}-msgheadermerge-temp.merge-dir/PO-Revision-Date
fi
fi
fi
# Old project version is the correct one:
rm -f ${2%.po}-msgheadermerge-temp.merge-dir/Project-Id-Version
mv ${2%.po}-msgheadermerge-temp.merge-dir/* ${1%.po}-msgheadermerge-temp.merge-dir/
cat ${1%.po}-msgheadermerge-temp.order >>${2%.po}-msgheadermerge-temp.order
msgmerge --quiet --force-po $2 $0-empty.pot -o ${2%.po}-msgheadermerge-tempheader.po
msgattrib --no-obsolete --force-po ${2%.po}-msgheadermerge-tempheader.po -o ${2%.po}-msgheadermerge-tempheader1.po
msgfilter --force-po -i ${2%.po}-msgheadermerge-tempheader1.po -o $3 $0-compose ${1%.po}-msgheadermerge-temp.merge-dir ${2%.po}-msgheadermerge-temp.order
exit $RC