我正在使用Angular Internationalization (i18n)以两种不同的语言 (fa/en) 开发应用程序。
我可以提供任何这样的本地化(语言)
"architect": {
"build": {
...
,
"configurations": {
...
},
"fa": {
"localize": ["fa"],
"baseHref": "/fa/"
},
"en": {
"localize": ["en"],
"baseHref": "/en/"
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
},
"en": {
"browserTarget": "app:build:en"
},
"fa": {
"browserTarget": "app:build:fa"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app:build"
}
},
...
}
Run Code Online (Sandbox Code Playgroud)
然后ng serve …
请告知如何修复此错误,我正在尝试实现本地化,但遇到了此问题。我使用的指南: https: //angular.io/guide/i18n#merge-translations-into-the-app 如果有帮助,我可以使用 ngserve --configuration=ru --open 运行并且应用程序已本地化,但是在我使用 _build.bat 之后,它破坏了我的应用程序,我根本无法再运行它。如果我指定不同的端口,则会抛出错误“NGCC 失败”。这是我的 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": { …Run Code Online (Sandbox Code Playgroud)