Is it possible that angular serve’s specific translation in development mode?
I followed dev-guide for i18n-merge
to apply specific build options for just one locale. But if running ng serve --configuration=en
, then the default baseHref
is displayed (“http://localhost:4200/de/”) and if I switch to “http://localhost:4200/en/” I got the following messge:
The server is configured with a public base URL of /de – did you mean
to visit /de/en/ instead?
My setup:
$ ng new test --ssr --no-standalone
$ cd test
$ ng add @angular/localize
$ ng add ng-extract-i18n-merge
angular.json:
{
...
"projects": {
"test": {
"projectType": "application",
...
"i18n": {
"sourceLocale": "de",// <---
"locales": {
"en": {
"translation": "src/locale/messages.en.xlf",// <---
"baseHref": "/en/"// <---
}
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"localize": true,// <---
"i18nMissingTranslation": "error",// <---
"outputPath": "dist/test",
...
},
"configurations": {
"production": {
...
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"localize": ["de"],// <---
"baseHref": "/de/"// <---
},
"en": {
"localize": ["en"] // <---
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
...
"development": {
"buildTarget": "test:build:development"
},
"en": {
"buildTarget": "test:build:development,en"// <---
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "ng-extract-i18n-merge:ng-extract-i18n-merge",// "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "test:build",
"format": "xlf2",// <---
"outputPath": "src/locale",
"targetFiles": ["messages.en.xlf"]// <---
}
},
...
}