LP#1775466 Improve locale building
authorBill Erickson <berickxx@gmail.com>
Fri, 24 Aug 2018 16:26:54 +0000 (12:26 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 24 Aug 2018 16:28:51 +0000 (12:28 -0400)
Break string export and merge into multiple steps to more easily
accomodate other locales down the road.

Adds script to stamp the locale-specific index.html file (for fr-CA only
now) so users don't have to do it manually.  For now, this command is
still locale-specific, but we should be able to further generify down
the road.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/README.adoc
Open-ILS/src/eg2/package.json

index 3dc9b43..1e51e6d 100644 (file)
@@ -92,25 +92,17 @@ ng lint
 === OPTIONAL: Building for an alternate locale
 
 * Using fr-CA as an example.
-* An fr-CA configuration is supplied by default.
+* An fr-CA configuration is supplied by default.  Additional configs
+  must be added where needed.
 * Currently translation builds are only available on --prod build mode.
 * Uncomment the locale lines in eg_vhost.conf and restart apache.
 
 [source,sh]
 ---------------------------------------------------------------------
-npm run build-translations
-# Modify some <target> entries in src/locale/messages.fr-CA.xlf to test
-ng build --configuration=production-fr-CA --output-path ../../web/eg2/fr-CA --deploy-url /eg2/fr-CA/ --base-href /eg2/fr-CA
----------------------------------------------------------------------
-
-* Currently, the IDL import has to be manually modified in 
-  ../../web/eg2/fr-CA/index.html like so:
-* TODO: create a script to do this and modify the "lang" attribute
-  for alt locales.
-
-[source,html]
----------------------------------------------------------------------
-<script src="/js/dojo/opensrf/JSON_v1.js?locale=fr-CA"></script>
+npm run export-strings
+npm run merge-strings -- fr-CA
+# APPLY TRANSLATIONS TO src/locale/messages.fr-CA.xlf
+npm run build-fr-CA
 ---------------------------------------------------------------------
 
 === Deploy
index b194c0f..d879203 100644 (file)
@@ -10,7 +10,9 @@
     "lint": "ng lint",
     "e2e": "ng e2e",
     "create-mock-idl": "cd src/test_data && perl idl2js.pl",
-    "build-translations": "ng xi18n --output-path locale && xliffmerge fr-CA"
+    "export-strings": "ng xi18n --output-path locale",
+    "merge-strings": "xliffmerge",
+    "build-fr-CA": "ng build --configuration=production-fr-CA --output-path ../../web/eg2/fr-CA --deploy-url /eg2/fr-CA/ --base-href /eg2/fr-CA; sed -i s/IDL2js\\\"/IDL2js?locale=fr-CA\\\"/g ../../web/eg2/fr-CA/index.html; sed -i s/lang=\\\"en\\\"/lang=\\\"fr\\\"/g ../../web/eg2/fr-CA/index.html"
   },
   "private": true,
   "dependencies": {