From 0dbc36d2663b35d2309b6cfb706eb420226734cd Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 20 Mar 2019 14:38:44 -0400 Subject: [PATCH] LP1821067 Angular i18n uses XMB; cs-CZ examples Includes documentation updates and cs-CZ example using export cs-CZ .xtb translation bundle. Also remove xmliffmerge configuration options since we are not using xliff files. Signed-off-by: Bill Erickson Signed-off-by: Dan Wells --- Open-ILS/src/eg2/CHEAT_SHEET.adoc | 23 ++++++++++++---- Open-ILS/src/eg2/angular.json | 8 +++--- Open-ILS/src/eg2/package.json | 31 ++-------------------- .../src/eg2/src/environments/environment.prod.ts | 3 ++- 4 files changed, 26 insertions(+), 39 deletions(-) diff --git a/Open-ILS/src/eg2/CHEAT_SHEET.adoc b/Open-ILS/src/eg2/CHEAT_SHEET.adoc index 84f4e5dd6c..2b90def39c 100644 --- a/Open-ILS/src/eg2/CHEAT_SHEET.adoc +++ b/Open-ILS/src/eg2/CHEAT_SHEET.adoc @@ -14,18 +14,31 @@ ng build --prod # compile production mode == OPTIONAL: Adding a Locale -* Using fr-CA as an example. -* An fr-CA configuration is supplied by default. Additional configs +* Using cs-CZ as an example. +* A cs-CZ 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. * TODO: expand docs on package.json file changes required to add locales. +=== Exporting Source Strings + [source,sh] --------------------------------------------------------------------- npm run export-strings -npm run merge-strings -- fr-CA -# APPLY TRANSLATIONS TO src/locale/messages.fr-CA.xlf -npm run build-fr-CA # modify package.json for other locales +--------------------------------------------------------------------- + +* Then upload the messages.xmb file to the translation service + +=== Import and Build the Translation + +1. Edit the "locales" array ./src/environments/environment.prod.ts to + include cs-CZ. +2. Export translations as ".XTB" files from translation service. +3. Put the file in src/locale/messages.cs-CZ.xtb +4. Build the application for the selected locale by running: +[source,sh] +--------------------------------------------------------------------- +npm run build-cs-CZ --------------------------------------------------------------------- diff --git a/Open-ILS/src/eg2/angular.json b/Open-ILS/src/eg2/angular.json index e50c8db5f7..ee7329df0c 100644 --- a/Open-ILS/src/eg2/angular.json +++ b/Open-ILS/src/eg2/angular.json @@ -45,7 +45,7 @@ } ] }, - "production-fr-CA": { + "production-cs-CZ": { "optimization": true, "outputHashing": "all", "sourceMap": false, @@ -55,9 +55,9 @@ "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, - "i18nFile": "src/locale/messages.fr-CA.xlf", - "i18nFormat": "xlf", - "i18nLocale": "fr-CA", + "i18nFile": "src/locale/messages.cs-CZ.xtb", + "i18nFormat": "xtb", + "i18nLocale": "cs-CZ", "i18nMissingTranslation": "ignore", "fileReplacements": [ { diff --git a/Open-ILS/src/eg2/package.json b/Open-ILS/src/eg2/package.json index 0c57e46406..0da357937a 100644 --- a/Open-ILS/src/eg2/package.json +++ b/Open-ILS/src/eg2/package.json @@ -9,9 +9,8 @@ "lint": "ng lint", "e2e": "ng e2e", "create-mock-idl": "cd src/test_data && perl idl2js.pl", - "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" + "export-strings": "ng xi18n --output-path locale --i18n-format xmb", + "build-cs-CZ": "ng build --configuration=production-cs-CZ --output-path ../../web/eg2/cs-CZ --deploy-url /eg2/cs-CZ/ --base-href /eg2/cs-CZ; sed -i s/IDL2js\\\"/IDL2js?locale=cs-CZ\\\"/g ../../web/eg2/cs-CZ/index.html; sed -i s/lang=\\\"en\\\"/lang=\\\"cs\\\"/g ../../web/eg2/cs-CZ/index.html" }, "private": true, "dependencies": { @@ -55,31 +54,5 @@ "ts-node": "~5.0.1", "tslint": "~5.9.1", "typescript": "~3.1.6" - }, - "xliffmergeOptions": { - "srcDir": "src/locale", - "genDir": "src/locale", - "i18nFile": "messages.xlf", - "i18nBaseFile": "messages", - "i18nFormat": "xlf", - "encoding": "UTF-8", - "defaultLanguage": "en", - "languages": [ - "en", - "fr-CA" - ], - "removeUnusedIds": true, - "supportNgxTranslate": false, - "ngxTranslateExtractionPattern": "@@|ngx-translate", - "useSourceAsTarget": true, - "targetPraefix": "", - "targetSuffix": "", - "beautifyOutput": false, - "allowIdChange": false, - "autotranslate": false, - "apikey": "", - "apikeyfile": "", - "verbose": false, - "quiet": false } } diff --git a/Open-ILS/src/eg2/src/environments/environment.prod.ts b/Open-ILS/src/eg2/src/environments/environment.prod.ts index df78657ddf..d7953f9f8a 100644 --- a/Open-ILS/src/eg2/src/environments/environment.prod.ts +++ b/Open-ILS/src/eg2/src/environments/environment.prod.ts @@ -1,5 +1,6 @@ export const environment = { production: true, - // locales: ['en-US', 'fr-CA'] + // TODO: a way to pass these in at build time. + // locales: ['en-US', 'fr-CA', 'cs-CZ'] locales: ['en-US'] }; -- 2.11.0