From 00b1bbdf64ee84bb5852ac587b2935c1c6bc2e87 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 9 Aug 2009 16:09:06 +0200 Subject: [PATCH] autopoint now supports multiple PO directories. --- Admin/plans | 3 - NEWS | 2 + gettext-tools/misc/ChangeLog | 10 ++++ gettext-tools/misc/autopoint.in | 99 +++++++++++++++++++++++++-------- 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/Admin/plans b/Admin/plans index 483277074..caf5268b4 100644 --- a/Admin/plans +++ b/Admin/plans @@ -61,9 +61,6 @@ Things we plan to do. Comments welcome. - Support some of the conversions found in the translate-toolkit package, see http://translate.sourceforge.net/wiki/nonpo -- Extend gettextize and autopoint so that they work with several PO file - directories. (2 votes) - - xgettext should have a simpler way to specify the --flags. - man page pgettext.3 diff --git a/NEWS b/NEWS index 6870a42e5..349c68d2b 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,8 @@ Version 0.18 - January 2008 used in the Fortran front-end of the GCC compiler, and marks them as 'gfc-internal-format'. +* autopoint can now be used to update several PO directories all together. + * Updated the meaning of 'gcc-internal-format' to match GCC 4.3. * Portability: diff --git a/gettext-tools/misc/ChangeLog b/gettext-tools/misc/ChangeLog index aaf789b51..76ace4617 100644 --- a/gettext-tools/misc/ChangeLog +++ b/gettext-tools/misc/ChangeLog @@ -1,3 +1,13 @@ +2009-08-09 Bruno Haible + + Add support for multiple PO directories to autopoint. + * autopoint.in (sed_extract_config_files, configfiles, + sed_remove_Makefile_in, podirs): New variables. + (func_destfile): Set allpodirs. + When allpodirs is set, loop over $podirs. + Reported by Guillem Jover + via Santiago Vila . + 2008-12-07 Bruno Haible * autopoint.in (func_version): Bump copyright year. diff --git a/gettext-tools/misc/autopoint.in b/gettext-tools/misc/autopoint.in index accd4cf29..2a5deeaa1 100644 --- a/gettext-tools/misc/autopoint.in +++ b/gettext-tools/misc/autopoint.in @@ -1,6 +1,6 @@ #! /bin/sh # -# Copyright (C) 2002-2008 Free Software Foundation, Inc. +# Copyright (C) 2002-2009 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -375,6 +375,34 @@ fi omitintl=`cat "$configure_in" | grep '^AM_GNU_GETTEXT' | sed -n -e 's/^AM_GNU_GETTEXT(\([^(),]*\).*$/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q` omitintl=`if test 'external' = "$omitintl"; then echo yes; fi` +# Check in which directory or directories the po/* infrastructure belongs. +sed_extract_config_files='s,#.*$,, +s,^dnl .*$,, +s, dnl .*$,, +/AC_CONFIG_FILES(/ { + ta + :a + s/)/)/ + tb + s/\\$// + N + ba + :b + s,^.*AC_CONFIG_FILES([[ ]*\([^]"$`\\)]*\).*$,\1,p +}' +configfiles=`cat "$configure_in" | sed -n -e "$sed_extract_config_files"` +# PO directories have a Makefile.in generated from Makefile.in.in. +# Treat a directory as a PO directory if and only if it has a +# POTFILES.in file. This allows packages to have multiple PO +# directories under different names or in different locations. +sed_remove_Makefile_in='s,/Makefile\.in$,,' +podirs=`for f in $configfiles; do case "$f" in */Makefile.in) echo $f;; esac; done | sed -e "$sed_remove_Makefile_in"` +if test -z "$podirs"; then + # If we cannot get the list of PO directories from configure.ac, assume the + # common default. + podirs="po" +fi + # Set up a temporary CVS repository and a temporary checkout directory. # We need the temporary CVS repository because any checkout needs write # access to the CVSROOT/history file, so it cannot be under $gettext_dir. @@ -448,6 +476,7 @@ cd .. # empty if the file shall be omitted # - sharedowner yes if the file is not only owned by GNU gettext but may # be installed by automake or other tools, otherwise empty +# - allpodirs yes if the file is to be installed in every dir in $podirs func_destfile () { # There are five categories of files: @@ -455,8 +484,9 @@ func_destfile () # config.rpath mkinstalldirs -> $auxdir # m4/* -> $m4dir/ # intl/* -> intl/ - # po/* -> po/ + # po/* -> sharedowner= + allpodirs= case `echo "$1" | sed -e 's,[^/]*$,,'` in "" ) case "$1" in @@ -467,6 +497,7 @@ func_destfile () ;; m4/ ) destfile=`echo "$1" | sed -e "s,^m4/,$m4dir/,"` ;; intl/ ) if test -n "$omitintl"; then destfile=""; else destfile="$1"; fi ;; + po/ ) destfile=`echo "$1" | sed -e "s,^po/,,"` allpodirs=yes ;; * ) destfile="$1" ;; esac } @@ -516,16 +547,27 @@ if test -z "$force"; then for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do func_destfile "$file" if test -n "$destfile"; then - if test -f "$destfile"; then - if func_compare "$destfile" "$work_dir/archive/$file"; then - if test -n "$sharedowner"; then - echo "autopoint: warning: File $destfile has been locally modified." 1>&2 - else - echo "autopoint: File $destfile has been locally modified." 1>&2 - mismatch=yes - diff -c "$work_dir/archive/$file" "$destfile" | sed -e "1s,$work_dir/archive/,," >> "$mismatchfile" + func_compare_to_destfile () + { + finaldestfile="$1" + if test -f "$finaldestfile"; then + if func_compare "$finaldestfile" "$work_dir/archive/$file"; then + if test -n "$sharedowner"; then + echo "autopoint: warning: File $finaldestfile has been locally modified." 1>&2 + else + echo "autopoint: File $finaldestfile has been locally modified." 1>&2 + mismatch=yes + diff -c "$work_dir/archive/$file" "$finaldestfile" | sed -e "1s,$work_dir/archive/,," >> "$mismatchfile" + fi fi fi + } + if test -n "$allpodirs"; then + for dir in $podirs; do + func_compare_to_destfile "$dir/$destfile" + done + else + func_compare_to_destfile "$destfile" fi fi done @@ -582,25 +624,36 @@ func_backup () # Now copy the files. for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do func_destfile "$file" - mustcopy= if test -n "$destfile"; then - if test -f "$destfile"; then - if func_compare "$destfile" "$work_dir/archive/$file"; then - if test -n "$force"; then - # Overwrite locally modified file. - mustcopy=yes + func_copy_to_destfile () + { + finaldestfile="$1" + mustcopy= + if test -f "$finaldestfile"; then + if func_compare "$finaldestfile" "$work_dir/archive/$file"; then + if test -n "$force"; then + # Overwrite locally modified file. + mustcopy=yes + fi + # If --force is not specified, don't overwrite locally modified files + # for which GNU gettext is a shared owner. fi - # If --force is not specified, don't overwrite locally modified files - # for which GNU gettext is a shared owner. + else + mustcopy=yes + fi + if test -n "$mustcopy"; then + func_backup "$finaldestfile" + func_copy "$work_dir/archive/$file" "$finaldestfile" fi + } + if test -n "$allpodirs"; then + for dir in $podirs; do + func_copy_to_destfile "$dir/$destfile" + done else - mustcopy=yes + func_copy_to_destfile "$destfile" fi fi - if test -n "$mustcopy"; then - func_backup "$destfile" - func_copy "$work_dir/archive/$file" "$destfile" - fi done # That's it. -- 2.47.3