Commit 3ec831a4 authored by anonym's avatar anonym
Browse files

Merge remote-tracking branch 'origin/bugfix/12641+potfile_line_comments' into devel

Fix-committed: #12641
parents df46a556 8391f358
...@@ -8,12 +8,12 @@ po_languages () { ...@@ -8,12 +8,12 @@ po_languages () {
} }
diff_without_pot_creation_date () { diff_without_pot_creation_date () {
old="$1" diff --ignore-matching-lines '^"POT-Creation-Date:' "${@}"
new="$2" }
[ $(diff "$old" "$new" | grep -Ec '^>') -eq 1 -a \ diff_without_pot_creation_date_and_comments () {
$(diff "$old" "$new" | grep -Ec '^<') -eq 1 -a \ diff --ignore-matching-lines '^"POT-Creation-Date:' \
$(diff "$old" "$new" | grep -Ec '^[<>] "POT-Creation-Date:') -eq 2 ] --ignore-matching-lines '^#: .*:[0-9]\+$' "${@}"
} }
intltool_update_po () { intltool_update_po () {
...@@ -25,11 +25,14 @@ intltool_update_po () { ...@@ -25,11 +25,14 @@ intltool_update_po () {
[ -f ${locale}.po ] || continue [ -f ${locale}.po ] || continue
[ -f ${locale}.po.new ] || continue [ -f ${locale}.po.new ] || continue
if diff_without_pot_creation_date "${locale}.po" "${locale}.po.new"; then if [ "${FORCE}" = yes ]; then
echo "${locale}: Only header changes in potfile, delete new PO file." echo "Force-updating '${locale}.po'."
mv ${locale}.po.new ${locale}.po
elif diff_without_pot_creation_date -q "${locale}.po" "${locale}.po.new"; then
echo "${locale}: Only header changes in PO file: keeping the old one"
rm ${locale}.po.new rm ${locale}.po.new
else else
echo "${locale}: Real changes in potfile: substitute old PO file." echo "${locale}: Real changes in PO file: switching to the updated one"
mv ${locale}.po.new ${locale}.po mv ${locale}.po.new ${locale}.po
fi fi
done done
......
...@@ -28,6 +28,12 @@ LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale ...@@ -28,6 +28,12 @@ LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
### Functions ### Functions
normalize_pot () {
sed --regexp-extended \
-i 's@^"Content-Type: text/plain; charset=CHARSET\\n"@"Content-Type: text/plain; charset=UTF-8\\n"@' \
"${@}"
}
prog_potfile () { prog_potfile () {
prog=$1 prog=$1
...@@ -43,19 +49,20 @@ prog_potfile () { ...@@ -43,19 +49,20 @@ prog_potfile () {
echo "tmp/pot/${domain}.pot" echo "tmp/pot/${domain}.pot"
} }
refresh_pot () { create_pot () {
prog=$1 prog=$1
proglang=$2 proglang=$2
progpath="config/chroot_local-includes${prog}"
progpath="config/chroot_local-includes$prog"
pot=$(prog_potfile $prog)
mkdir -p "$(dirname $pot)"
if [ -e "${progpath}" ]; then if [ -e "${progpath}" ]; then
pot="$(prog_potfile "${prog}")"
mkdir -p "$(dirname ${pot})"
xgettext --language="${proglang}" --from-code=UTF-8 \ xgettext --language="${proglang}" --from-code=UTF-8 \
-o "${pot}" "${progpath}" -o "${pot}" "${progpath}"
sed -i "s@^\"Content-Type: text/plain\; charset=CHARSET\\\n\"@\"Content-Type: text/plain\; charset=UTF-8\\\n\"@" "${pot}" normalize_pot "${pot}"
else
echo "error: We are supposed to create a POT file for '${prog}'" \
"but '${progpath}' does not exist"
exit 1
fi fi
} }
...@@ -91,12 +98,16 @@ intltool_update_pot () { ...@@ -91,12 +98,16 @@ intltool_update_pot () {
cd po cd po
cp -a tails.pot tails.pot.orig cp -a tails.pot tails.pot.orig
intltool-update --pot --gettext-package=tails intltool-update --pot --gettext-package=tails
normalize_pot tails.pot tails.pot.orig
if diff_without_pot_creation_date tails.pot.orig tails.pot ; then if [ "${FORCE}" = yes ]; then
echo "Only header changes in tails.pot, restoring the old one." echo "Force-updating 'tails.pot'."
rm tails.pot.orig
elif diff_without_pot_creation_date_and_comments -q tails.pot.orig tails.pot; then
echo "Only header or comment changes in tails.pot: keeping the old one"
mv tails.pot.orig tails.pot mv tails.pot.orig tails.pot
else else
echo "Real changes in tails.pot: keeping the updated one." echo "Real changes in tails.pot: switching to the updated one"
rm tails.pot.orig rm tails.pot.orig
fi fi
) )
...@@ -112,12 +123,29 @@ intltool_merge () { ...@@ -112,12 +123,29 @@ intltool_merge () {
### Main ### Main
# Schedule clean up
trap "rm -fr tmp/pot po/*.new po/*.orig" EXIT
FORCE=no
while [ -n "${@:-}" ]; do
case "${1:-}" in
'--force')
FORCE=yes
;;
*)
echo "Unknown option: ${1}"
exit 1
;;
esac
shift
done
# Update POT files # Update POT files
mkdir -p tmp/pot mkdir -p tmp/pot
for prog in $PERL_PROGS ; do refresh_pot $prog Perl ; done for prog in $PERL_PROGS ; do create_pot $prog Perl ; done
for prog in $PYTHON_PROGS ; do refresh_pot $prog Python ; done for prog in $PYTHON_PROGS ; do create_pot $prog Python ; done
for prog in $SHELL_PROGS ; do refresh_pot $prog Shell ; done for prog in $SHELL_PROGS ; do create_pot $prog Shell ; done
for prog in $JAVASCRIPT_PROGS ; do refresh_pot $prog JavaScript ; done for prog in $JAVASCRIPT_PROGS ; do create_pot $prog JavaScript ; done
intltool_update_pot intltool_update_pot
# If left out files are detected, intltool-update --maintain writes # If left out files are detected, intltool-update --maintain writes
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment