]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
autopoint now supports multiple PO directories.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Aug 2009 14:09:06 +0000 (16:09 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Aug 2009 14:09:06 +0000 (16:09 +0200)
Admin/plans
NEWS
gettext-tools/misc/ChangeLog
gettext-tools/misc/autopoint.in

index 483277074e551fe671baac8777afc7b0e5c92460..caf5268b488ec6fed44bf18fc2911cf3ad87536a 100644 (file)
@@ -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 6870a42e53a2c415f678ff2684be8e0582db1aa6..349c68d2b73523b3837a7173f081cf800e7438dd 100644 (file)
--- 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:
index aaf789b510c19c6173ece36e3a278e66d2941648..76ace4617f78588d30bb82818010a3818286b41b 100644 (file)
@@ -1,3 +1,13 @@
+2009-08-09  Bruno Haible  <bruno@clisp.org>
+
+       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 <guillem@debian.org>
+       via Santiago Vila <sanvila@unex.es>.
+
 2008-12-07  Bruno Haible  <bruno@clisp.org>
 
        * autopoint.in (func_version): Bump copyright year.
index accd4cf29fa3442da9c85179cbd4b96e53fb903b..2a5deeaa1f111b64e3d8641c67b4cd1eceab31bd 100644 (file)
@@ -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.