From 8cc56c7fddb4c9fe3cfe1a19f340fc07dc4cec0f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Feb 2020 11:34:34 +0100 Subject: [PATCH] Only use basehref Will allow us to use the localize option --- client/angular.json | 51 +++++++++++++++++++----------------- client/src/app/app.module.ts | 6 +++++ scripts/build/client.sh | 7 ++--- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/client/angular.json b/client/angular.json index bf3a860aa..d9cee9bac 100644 --- a/client/angular.json +++ b/client/angular.json @@ -8,99 +8,102 @@ "sourceRoot": "src", "projectType": "application", "i18n": { - "sourceLocale": "en", + "sourceLocale": { + "code": "en", + "baseHref": "/client/en-US/" + }, "locales": { "hu": { "translation": "src/locale/angular.hu-HU.xlf", - "baseHref": "/" + "baseHref": "/client/hu-HU/" }, "th": { "translation": "src/locale/angular.th-TH.xlf", - "baseHref": "/" + "baseHref": "/client/th-TH/" }, "fi": { "translation": "src/locale/angular.fi-FI.xlf", - "baseHref": "/" + "baseHref": "/client/fi-FI/" }, "nl": { "translation": "src/locale/angular.nl-NL.xlf", - "baseHref": "/" + "baseHref": "/client/nl-NL/" }, "gd": { "translation": "src/locale/angular.gd.xlf", - "baseHref": "/" + "baseHref": "/client/gd/" }, "el": { "translation": "src/locale/angular.el-GR.xlf", - "baseHref": "/" + "baseHref": "/client/el-GR/" }, "es": { "translation": "src/locale/angular.es-ES.xlf", - "baseHref": "/" + "baseHref": "/client/es-ES/" }, "oc": { "translation": "src/locale/angular.oc.xlf", - "baseHref": "/" + "baseHref": "/client/oc/" }, "pt": { "translation": "src/locale/angular.pt-BR.xlf", - "baseHref": "/" + "baseHref": "/client/pt-BR/" }, "pt-PT": { "translation": "src/locale/angular.pt-PT.xlf", - "baseHref": "/" + "baseHref": "/client/pt-PT/" }, "sv": { "translation": "src/locale/angular.sv-SE.xlf", - "baseHref": "/" + "baseHref": "/client/sv-SE/" }, "pl": { "translation": "src/locale/angular.pl-PL.xlf", - "baseHref": "/" + "baseHref": "/client/pl-PL/" }, "ru": { "translation": "src/locale/angular.ru-RU.xlf", - "baseHref": "/" + "baseHref": "/client/ru-RU/" }, "zh-Hans": { "translation": "src/locale/angular.zh-Hans-CN.xlf", - "baseHref": "/" + "baseHref": "/client/zh-Hans-CN/" }, "zh-Hant": { "translation": "src/locale/angular.zh-Hant-TW.xlf", - "baseHref": "/" + "baseHref": "/client/zh-Hant-TW/" }, "fr": { "translation": "src/locale/angular.fr-FR.xlf", - "baseHref": "/" + "baseHref": "/client/fr-FR/" }, "ja": { "translation": "src/locale/angular.ja-JP.xlf", - "baseHref": "/" + "baseHref": "/client/ja-JP/" }, "eu": { "translation": "src/locale/angular.eu-ES.xlf", - "baseHref": "/" + "baseHref": "/client/eu-ES/" }, "ca": { "translation": "src/locale/angular.ca-ES.xlf", - "baseHref": "/" + "baseHref": "/client/ca-ES/" }, "cs": { "translation": "src/locale/angular.cs-CZ.xlf", - "baseHref": "/" + "baseHref": "/client/cs-CZ/" }, "eo": { "translation": "src/locale/angular.eo.xlf", - "baseHref": "/" + "baseHref": "/client/eo/" }, "de": { "translation": "src/locale/angular.de-DE.xlf", - "baseHref": "/" + "baseHref": "/client/de-DE/" }, "it": { "translation": "src/locale/angular.it-IT.xlf", - "baseHref": "/" + "baseHref": "/client/it-IT/" } } }, diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 14fdb7588..d11dba34d 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -18,6 +18,7 @@ import { SearchModule } from '@app/search' import { WelcomeModalComponent } from '@app/modal/welcome-modal.component' import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-warning-modal.component' import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/models' +import { APP_BASE_HREF } from '@angular/common' export function metaFactory (serverService: ServerService): MetaLoader { return new MetaStaticLoader({ @@ -67,6 +68,11 @@ export function metaFactory (serverService: ServerService): MetaLoader { ], providers: [ + { + provide: APP_BASE_HREF, + useValue: '/' + }, + { provide: TRANSLATIONS, useFactory: (locale: string) => { diff --git a/scripts/build/client.sh b/scripts/build/client.sh index 99394838a..aa3f89c03 100755 --- a/scripts/build/client.sh +++ b/scripts/build/client.sh @@ -76,10 +76,11 @@ if [ -z ${1+x} ] || [ "$1" != "--light" ]; then # TODO: remove when the project will use runtime translations pre_build_hook "$lang" - npm run ng build -- --output-path "dist/build" --deploy-url "/client/$lang/" --prod --configuration="$lang" + npm run ng build -- --prod --configuration="$lang" - mv "dist/build/$key" "dist/$lang" - rmdir "dist/build" + if [ ! "$lang" = "$key" ]; then + mv "dist/$key" "dist/$lang" + fi # Do not duplicate assets rm -r "./dist/$lang/assets" -- 2.25.1