angular - 发生未处理的异常:开发服务器仅支持每次构建本地化单个语言环境
问题描述
请告知如何修复此错误,我正在尝试实施本地化但遇到此问题。我使用的指南:https ://angular.io/guide/i18n#merge-translations-into-the-app 如果有帮助,我可以使用 ng serve --configuration=ru --open 运行,并且应用程序已本地化,但是在我使用 _build.bat 之后,它破坏了我的应用程序,我根本无法再运行它。如果我指定不同的端口,则会引发错误“NGCC failed”。这是 angular.json 文件中我的代码示例:
"projects": {
"operator": {
"i18n": {
"sourceLocale": "en-US",
"locales": {
"ru": "src/locale/messages.ru.xlf"
}
},
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/operator",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"localize": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": ["src/version.js"]
},
"configurations": {
"ru": {
"localize": ["ru"]
},
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "3mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "operator:build"
},
"configurations": {
"production": {
"browserTarget": "operator:build:production"
},
"ru": {
"browserTarget": "operator:build:ru"
}
}
}
解决方案
在我删除“localize”后:true,错误从未出现。
推荐阅读
- python - 在 matplotlib 标签中使用 mathfrak 返回未定义的控制序列
- iis - 无法登录 IIS 应用程序
- flutter - 包导入和文件导入有什么区别?
- terraform - 如何使用 Terratest 测试我的资源是否可以免受意外破坏?
- android - 根据焦点状态自定义搜索栏并显示搜索栏拇指
- android-studio - 在 Android Studio 中添加 @SerializedName 注解的快捷方式
- laravel - Laravel API 从数据库中删除行
- redmine - OpenProject 接收邮件问题
- android - 如何在 StatefulWidget 类中实现 Flutter 和 android 之间的通道?
- encryption - SELinux 和 cryptsetup:chown 失败,无法访问临时密钥库