]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Automatic Translation of .PO and Error Pages
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 5 Aug 2008 06:39:39 +0000 (18:39 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 5 Aug 2008 06:39:39 +0000 (18:39 +1200)
This patch embeds the process of creating pre-translated error templates
from .po

 * installs/uninstalls base templates for failover backup if no
   translation is to be done.
 * 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.

configure.in
errors/Makefile.am

index b8b8f64f5981e52ad3f89489202219d2448d5858..048f073216f48bd0a91951fbe2d638230cd29159 100755 (executable)
@@ -3694,6 +3694,23 @@ if test $ac_cv_have_res_ns_list = "yes" ; then
 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
index 1f4aaf45318afba8294def396d685ade5fb605a6..eaba5a95da75155c02e9bc55a5f37a8875dbe04c 100644 (file)
@@ -10,6 +10,12 @@ errordir = $(datadir)/errors
 
 DEFAULT_ERROR_DIR      = $(errordir)
 
+# List of automated translations possible:
+TRANSLATIONS = \
+       en
+
+# Legacy language contributions...
+#
 INSTALL_LANGUAGES      = @ERR_LANGUAGES@
 LANGUAGES      = \
                Armenian \
@@ -53,14 +59,30 @@ install-data-local:
                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) templates; 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 l in $(INSTALL_LANGUAGES); do \
                for f in $(srcdir)/$$l/ERR_*; do \
                        rm -f $(DESTDIR)$(DEFAULT_ERROR_DIR)/$$l/`basename $$f`; \
-               done \
+               done; \
+       done; \
+       for l in $(TRANSLATIONS) templates; 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 @@ uninstall-local:
 #
 # by Andres Kroonmaa <andre@mail.lbi.ee>
 #
+# 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
        -@if test -d $(srcdir)/$(ADDLANG); then \
        if test -d $(DEFAULT_ERROR_DIR)/$(DESTLANG); then \
@@ -85,7 +111,7 @@ addlang: all
        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,28 @@ dist-hook:
            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:
+       translate