当尝试使用不同的语言环境配置为我的 Angular v9 应用程序提供服务时,默认语言一直显示,同时ng build --localize
按预期工作。
node --max_old_space_size=4096 ./node_modules/.bin/ng serve -c=dev,sv --project=my-project-name
角.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"packageManager": "npm"
},
"newProjectRoot": "projects",
"projects": {
"my-project-name": {
"root": "apps/my-project-name/",
"sourceRoot": "apps/my-project-name/src/",
"projectType": "application",
"i18n": {
"sourceLocale": "en",
"locales": {
"sv": "i18n/messages.sv.xlf",
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {... // other options},
"configurations": {
"dev": {
"fileReplacements": [
{
"replace": "apps/my-project-name/src/environments/environment.ts",
"with": "apps/my-project-name/src/environments/environment.dev.ts"
}
]
},
//.. omitted config for staging & production.
"sv": {
"localize": ["sv"]
},
},
"i18nMissingTranslation": "error"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "my-project-name:build"
},
"configurations": {
"dev": {
"browserTarget": "my-project-name:build:dev"
},
"sv": {
"browserTarget": "my-project-name:build:sv"
},
}
},
}
}
}
}
Angular CLI: 9.1.1
Node: 10.19.0
OS: darwin x64
Angular: 9.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.901.1
@angular-devkit/build-angular 0.901.1
@angular-devkit/build-optimizer 0.901.1
@angular-devkit/build-webpack 0.901.1
@angular-devkit/core 9.1.1
@angular-devkit/schematics 9.1.1
@angular/cdk 9.2.1
@angular/flex-layout 9.0.0-beta.29
@angular/material 9.2.1
@angular/material-moment-adapter 9.2.1
@ngtools/webpack 9.1.1
@schematics/angular 9.1.0
@schematics/update 0.901.1
rxjs 6.5.5
typescript 3.8.3
webpack 4.42.0
我不确切知道缺少什么:任何帮助将不胜感激,谢谢。