Round 2 of these.

This is again;

Just the process of creating pre-translated error templates from .po

As it stands:
 * Adds dependency on translation toolkit po2html for 'make dist' target.
 * Adds 'make translate' target
 * Adjusts 'make all' to do translation.
* Adds --without-po2html configure option to optionally skip the translation step unless explicitly asked for ('make translate').
 * Installs translated files properly, and skips silently if missing.
 * Un-installs translated files, and skips silently if missing.

Amos
=== modified file 'configure.in'
--- configure.in	2008-07-11 19:32:10 +0000
+++ configure.in	2008-07-23 11:33:48 +0000
@@ -3694,6 +3694,23 @@
 fi
 fi
 
+dnl Squid now has limited locale handling ...
+DO_TRANSLATE="yes"
+AC_ARG_WITH(po2html,
+[  --without-po2html     Translation toolkit is required to auto-build translated
+                        error pages. If it is not present this option can be used
+                        to run the 'make dist' target without translating.
+                        A drop-in bundle of pre-translated files is available from
+                        http://www.squid-cache.org/Versions/v3/HEAD/
+],
+[ if test "$enableval" != "yes" ; then
+    echo "Disabling Translation Toolkit dependency"
+    DO_TRANSLATE="no"
+  fi
+])
+AC_SUBST(DO_TRANSLATE)
+
+
 dnl Need the debugging version of malloc if available
 XTRA_OBJS=''
 if test "$ac_cv_lib_malloc_main" = "yes" ; then

=== modified file 'errors/Makefile.am'
--- errors/Makefile.am	2008-02-24 19:10:30 +0000
+++ errors/Makefile.am	2008-07-23 11:34:26 +0000
@@ -10,6 +10,12 @@
 
 DEFAULT_ERROR_DIR	= $(errordir)
 
+# List of automated translations possible:
+TRANSLATIONS = \
+	en
+
+# Legacy language contributions...
+#
 INSTALL_LANGUAGES	= @ERR_LANGUAGES@
 LANGUAGES	= \
 		Armenian \
@@ -53,14 +59,30 @@
 		for f in $(srcdir)/$$l/ERR_*; do \
 			echo "$(INSTALL_DATA) $$f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l"; \
 			$(INSTALL_DATA) $$f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l; \
-		done \
+		done; \
+	done; \
+	for l in $(TRANSLATIONS) ; do \
+	  if test -d $(srcdir)/$$l; then \
+		$(mkinstalldirs) $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l && \
+		for f in $(srcdir)/$$l/ERR_*; do \
+			echo "$(INSTALL_DATA) $$f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l"; \
+			$(INSTALL_DATA) $$f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l; \
+		done; \
+	  fi \
 	done
 
 uninstall-local:
-	@for l in $(INSTALL_LANGUAGES); do \
-		for f in $(srcdir)/$$l/ERR_*; do \
-	        	rm -f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l/`basename $$f`; \
-		done \
+	@ for l in $(INSTALL_LANGUAGES); do \
+		for f in $(srcdir)/$$l/ERR_*; do \
+	        	rm -f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l/`basename $$f`; \
+		done; \
+	done; \
+	for l in $(TRANSLATIONS); do \
+	  if test -d $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l; then \
+		for f in $(srcdir)/$$l/ERR_*; do \
+	        	rm -f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l/`basename $$f`; \
+		done; \
+	  fi \
 	done
 
 # undocumented hack.  You can use this target to create multi-lingual
@@ -70,6 +92,10 @@
 #
 # by Andres Kroonmaa <[EMAIL PROTECTED]>
 #
+# UPDATE: this hack completely breaks HTML standards and with the addition
+#	  of language translations is now largely obsolete.
+#	  It will be removed without notice at some future date.
+#
 addlang: all
 	[EMAIL PROTECTED] test -d $(srcdir)/$(ADDLANG); then \
 	if test -d $(DEFAULT_ERROR_DIR)/$(DESTLANG); then \
@@ -85,7 +111,7 @@
 	fi
 
 dist-hook:
-	@ for lang in $(LANGUAGES); do \
+	for lang in $(LANGUAGES); do \
 	  if test "$$lang" = .; then :; else \
 	    test -d $(distdir)/$$lang \
 	    || mkdir $(distdir)/$$lang \
@@ -93,4 +119,30 @@
 	    cp -p $(srcdir)/$$lang/ERR_*  $(distdir)/$$lang \
 	      || exit 1; \
 	  fi; \
-	done		
+	done; \
+	if test "$(DO_TRANSLATE)" = "yes" ; then \
+		translate; \
+	fi
+
+translate:
+	for lang in $(TRANSLATIONS); do \
+		test -d $$lang || rm -r $$lang; \
+		mkdir $$lang; \
+		test -d $(distdir)/$$lang \
+		  || mkdir $(distdir)/$$lang \
+		  || exit 1; \
+		cd $$lang; \
+		for f in `ls -1 ../templates`; do \
+			echo "po2html -i ../$$lang.po -t ../templates/$$f"; \
+			po2html -i ../$$lang.po -t ../templates/$$f \
+			 | sed -r s/\>\ \ ?\</\>\\n\</g >$$f || exit 1; \
+		done; \
+		cd ..; \
+		cp -p $(srcdir)/$$lang/ERR_*  $(distdir)/$$lang \
+		  || exit 1; \
+	done
+
+all:
+	if test "$(DO_TRANSLATE)" = "yes" ; then \
+		translate; \
+	fi

=== modified file 'errors/update-pot.sh'
--- errors/update-pot.sh	2008-07-15 12:11:23 +0000
+++ errors/update-pot.sh	2008-07-23 11:33:48 +0000
@@ -1,4 +1,4 @@
-#/bin/sh
+#!/bin/sh
 #
 # Update the core dictionary file from the basic templates
 # Useful if any template has altered.
@@ -25,11 +25,12 @@
 	) >dictionary.pot
 
 # Update all existing dictionaries with the new content ...
-for f in `ls -1 ./*.po` ; do
-
-# NP: this does not yet fully work. Old dictionaries upgrading still needs a little work.
-
-#	msgmerge --verbose -s --no-wrap -o ${f}.new ${f} dictionary.pot
-
-	# TODO check that the merge actually removes translations which are now obsolete???
-done
+#for f in `ls -1 ./*.po` ; do
+#
+#
+## NP: this does not yet fully work. Old dictionaries upgrading still needs a little work.
+#
+##	msgmerge --verbose -s --no-wrap -o ${f}.new ${f} dictionary.pot
+#
+#	# TODO check that the merge actually removes translations which are now obsolete???
+#done

Reply via email to