From 4bbe2ae8bdeec90e000f35be8aad6b34518ad559 Mon Sep 17 00:00:00 2001
From: Dan Scott <dscott@laurentian.ca>
Date: Mon, 20 Aug 2012 14:11:50 -0400
Subject: [PATCH] TPAC: Standardize i18n file installation

Make TPAC i18n files act like any other i18n file. In short:

1. When in build/i18n, a 'make LOCALE=fr-CA install' will copy
   the i18n file into the Open-ILS/src/data/locale directory.
2. In the build root, a 'make install' will copy all files from
   Open-ILS/src/data/locale into (by default) the
   /openils/var/data/locale directory.

This also means that when tarballs are created, all of the locales will
get packaged appropriately.

This commit also updates eg_vhost.conf to provide working out-of-the-box
examples for any installed locales, by using the names of the actual
PO files, and adds some contextual comments to explain how the
configuration directives work.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
---
 Open-ILS/examples/apache/eg_vhost.conf | 15 ++++++++++++---
 Open-ILS/src/Makefile.am               |  4 ++++
 build/i18n/Makefile                    |  3 +++
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Open-ILS/examples/apache/eg_vhost.conf b/Open-ILS/examples/apache/eg_vhost.conf
index 0265d6666a..c2b4cd27ec 100644
--- a/Open-ILS/examples/apache/eg_vhost.conf
+++ b/Open-ILS/examples/apache/eg_vhost.conf
@@ -574,13 +574,22 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT]
     #PerlSetVar OILSWebMediaPrefix "static.example.com/media"
     #PerlSetVar OILSWebMediaPrefix "http://static.example.com/media"
 
-    # Locale messages files
+    # Locale messages files:
+    #
+    # These appear in pairs; the first represents the user agent
+    # Accept-Language header locale, and the second represents
+    # the fully-qualified path for the corresponding PO file that
+    # contains the messages.
+    #
+    # If you enable two or more locales, then users will be able to
+    # select their preferred locale from a locale picker in the TPAC.
+    #
     #PerlAddVar OILSWebLocale "en"
     #PerlAddVar OILSWebLocale "/openils/var/data/locale/messages.en.po"
     #PerlAddVar OILSWebLocale "en_ca"
-    #PerlAddVar OILSWebLocale "/openils/var/data/locale/messages.en_ca.po"
+    #PerlAddVar OILSWebLocale "/openils/var/data/locale/en-CA.po"
     #PerlAddVar OILSWebLocale "fr_ca"
-    #PerlAddVar OILSWebLocale "/openils/var/data/locale/messages.fr_ca.po"
+    #PerlAddVar OILSWebLocale "/openils/var/data/locale/fr-CA.po"
 
     # Templates will be loaded from the following paths in reverse order.
     PerlAddVar OILSWebTemplatePath "/openils/var/templates"
diff --git a/Open-ILS/src/Makefile.am b/Open-ILS/src/Makefile.am
index 8fe83020ff..42497a1383 100644
--- a/Open-ILS/src/Makefile.am
+++ b/Open-ILS/src/Makefile.am
@@ -153,6 +153,7 @@ data_DATA = $(core_data) $(reporter_data)
 SUBDIRS = $(OILSCORE_DIRS) $(OILSWEB_DIR) $(OILSPYTHON_DIR) $(OILSJAVA_DIR)
 
 EXTRA_DIST = @srcdir@/perlmods \
+	@srcdir@/data \
 	@srcdir@/templates \
 	@top_srcdir@/Open-ILS/xsl \
 	@srcdir@/cgi-bin \
@@ -218,6 +219,9 @@ ilscore-install:
 	$(MKDIR_P) $(DESTDIR)$(TEMPLATEDIR)
 	@echo "Installing templates to $(DESTDIR)$(TEMPLATEDIR)"
 	cp -r @srcdir@/templates/* $(DESTDIR)$(TEMPLATEDIR)
+	$(MKDIR_P) $(DESTDIR)$(datadir)/locale/
+	@echo "Installing template data files to $(datadir)/locale/"
+	cp @srcdir@/data/locale/* $(datadir)/locale/
 	$(MKDIR_P) $(DESTDIR)$(datadir)/overdue/
 	sed -i 's|LOCALSTATEDIR|@localstatedir@|g' '$(DESTDIR)@sysconfdir@/oils_sip.xml.example'
 	sed -i 's|SYSCONFDIR|@sysconfdir@|g' '$(DESTDIR)@sysconfdir@/oils_sip.xml.example'
diff --git a/build/i18n/Makefile b/build/i18n/Makefile
index 534f2dfdcb..343909a85e 100644
--- a/build/i18n/Makefile
+++ b/build/i18n/Makefile
@@ -6,6 +6,7 @@ POTLIST=$(shell ls -d po/*)
 DTDDIR=../../Open-ILS/web/opac/locale
 CHROME_PROPSDIR=../../Open-ILS/xul/staff_client/chrome/locale
 SERVER_PROPSDIR=../../Open-ILS/xul/staff_client/server/locale
+TT2_DATA_DIR=../../Open-ILS/src/data/locale
 DOJO_LOCALE := $(shell echo ${LOCALE} | tr '[:upper:]' '[:lower:]')
 DOJO_ACQ_SRC=../../Open-ILS/web/js/dojo/openils/acq/nls
 DOJO_ACTOR_SRC=../../Open-ILS/web/js/dojo/openils/actor/nls
@@ -317,6 +318,8 @@ install: updatepo project fmidl2fmidlent fmidlpo2entity-en
 	cp $(PROJECT)/$(LOCALE)/Searcher.js $(DOJO_WIDGET_SRC)/$(DOJO_LOCALE)/Searcher.js
 	cp $(PROJECT)/$(LOCALE)/TranslatorPopup.js $(DOJO_WIDGET_SRC)/$(DOJO_LOCALE)/TranslatorPopup.js
 	cp $(PROJECT)/$(LOCALE)/XULTermLoader.js $(DOJO_WIDGET_SRC)/$(DOJO_LOCALE)/XULTermLoader.js
+	mkdir -p $(TT2_DATA_DIR)
+	cp $(PO)/tpac/$(LOCALE).po $(TT2_DATA_DIR)/.
 
 install_all_locales: newpot
 	for i in `ls po/*/*po|grep -v en-US | cut -f3 -d'/' | cut -f1 -d. | sort | uniq`; \
-- 
2.11.0