i18n的配置:新的Angular渲染引擎Ivy的一部分包括一种新的应用程序本地化方法,特别是提取和翻译文本
"architect": {
"build": {
...
"options": {
...
}
"configurations": {
"production": {
"assets": [...],
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"outputPath": "dist/production/nl/",
"i18nFile": "src/locale/messages.nl.xlf",
"i18nLocale": "nl",
"baseHref": "/ngapp/nl/"
}
}
}
新配置更改如下,如果使用多种语言,将缩短构建时间https://blog.angular.io/angular-localization-with-ivy-4d8becefb6aa
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
...
},
"configurations": {
"production": {
"assets": [ ... ],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"aot": true,
"outputPath": "dist/production",
"serviceWorker": true,
"localize": [
"nl",
"en"
]
},
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "project:build"
},
"configurations": {
"production": {
"browserTarget": "project:build:production"
},
"en": {
"browserTarget": "project:build:en"
},
"nl": {
"browserTarget": "project:build:nl"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "project:build"
}
},
"i18n": {
"locales": {
"nl": {
"translation": "src/locale/messages.nl.xlf",
"baseHref": "/ngapp/nl/"
},
"en": {
"translation": "src/locale/messages.en.xlf",
"baseHref": "/ngapp/en/"
}
}
}
},