没有项目支持 'extract-i18n' 目标
No projects support the 'extract-i18n' target
我正在尝试在一个已有内部化的旧项目上添加新标签 Angular xi18n
如何重新生成 xlf 文件?
或者我可以手动将自己的传输单元插入到 xlf 文件中吗?如果可以,我可以制作自己的跨单元 ID 和行号吗?
因为当我尝试 ng xi18n 使用相同的路径时,我使用它 returns 出现以下错误:发生未处理的异常:没有项目支持 'extract-i18n' 目标。
[错误] 错误:没有项目支持 'extract-i18n' 目标。
at Xi18nCommand.initialize (C:\Project\src\webadmin\node_modules\@angular\cli\models\architect-command.js:53:19)
at async Xi18nCommand.validateAndRun (C:\Project\src\webadmin\node_modules\@angular\cli\models\command.js:124:9)
at async Object.runCommand (C:\Project\src\webadmin\node_modules\@angular\cli\models\command-runner.js:201:24)
at async default_1 (C:\Project\src\webadmin\node_modules\@angular\cli\lib\cli\index.js:62:31)
这是我的 angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"webadmin": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"i18n": {
"sourceLocale": "en",
"locales": {
"fr": "src/locale/messages.fr.xlf",
"de": "src/locale/messages.de.xlf"
}
},
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/webadmin",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets/"
},
{
"glob": "favicon.ico",
"input": "src",
"output": "/"
}
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"node_modules/ngx-toastr/toastr.css",
"src/styles.scss"
],
"scripts": [],
"es5BrowserSupport": true
},
"configurations": {
"production": {
"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,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"int": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.int.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"dev": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"local": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local.ts"
}
]
},
"fr": {
"localize": [
"fr"
],
"aot": true,
"i18nFile": "src/locale/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr"
},
"de": {
"localize": [
"de"
],
"aot": true,
"i18nFile": "src/locale/messages.de.xlf",
"i18nFormat": "xlf",
"i18nLocale": "de"
},
"de-int": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.int.ts"
}
],
"localize": [
"de"
],
"aot": true,
"i18nFile": "src/locale/messages.de.xlf",
"i18nFormat": "xlf",
"i18nLocale": "de"
},
"de-test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"localize": [
"de"
],
"aot": true,
"i18nFile": "src/locale/messages.de.xlf",
"i18nFormat": "xlf",
"i18nLocale": "de"
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "webadmin:build"
},
"configurations": {
"production": {
"browserTarget": "webadmin:build:production"
},
"local": {
"browserTarget": "webadmin:build:local"
},
"fr": {
"browserTarget": "webadmin:build:fr",
"aot": true
},
"de": {
"browserTarget": "webadmin:build:de"
},
"de-int": {
"browserTarget": "webadmin:build:de-int"
},
"de-test": {
"browserTarget": "webadmin:build:de-test"
}
}
}
}
}
},
"defaultProject": "webadmin",
"cli": {
"analytics": "9009c4ee-47f2-453c-af4a"
}
}
您需要使用 build
和 serve
目标定义一个 extract-i18n
长边目标:
"build": {
...
},
"serve": {
...
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "webadmin:build"
}
}
我正在尝试在一个已有内部化的旧项目上添加新标签 Angular xi18n
如何重新生成 xlf 文件? 或者我可以手动将自己的传输单元插入到 xlf 文件中吗?如果可以,我可以制作自己的跨单元 ID 和行号吗?
因为当我尝试 ng xi18n 使用相同的路径时,我使用它 returns 出现以下错误:发生未处理的异常:没有项目支持 'extract-i18n' 目标。 [错误] 错误:没有项目支持 'extract-i18n' 目标。
at Xi18nCommand.initialize (C:\Project\src\webadmin\node_modules\@angular\cli\models\architect-command.js:53:19)
at async Xi18nCommand.validateAndRun (C:\Project\src\webadmin\node_modules\@angular\cli\models\command.js:124:9)
at async Object.runCommand (C:\Project\src\webadmin\node_modules\@angular\cli\models\command-runner.js:201:24)
at async default_1 (C:\Project\src\webadmin\node_modules\@angular\cli\lib\cli\index.js:62:31)
这是我的 angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"webadmin": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"i18n": {
"sourceLocale": "en",
"locales": {
"fr": "src/locale/messages.fr.xlf",
"de": "src/locale/messages.de.xlf"
}
},
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/webadmin",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets/"
},
{
"glob": "favicon.ico",
"input": "src",
"output": "/"
}
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"node_modules/ngx-toastr/toastr.css",
"src/styles.scss"
],
"scripts": [],
"es5BrowserSupport": true
},
"configurations": {
"production": {
"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,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"int": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.int.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"dev": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"local": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local.ts"
}
]
},
"fr": {
"localize": [
"fr"
],
"aot": true,
"i18nFile": "src/locale/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr"
},
"de": {
"localize": [
"de"
],
"aot": true,
"i18nFile": "src/locale/messages.de.xlf",
"i18nFormat": "xlf",
"i18nLocale": "de"
},
"de-int": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.int.ts"
}
],
"localize": [
"de"
],
"aot": true,
"i18nFile": "src/locale/messages.de.xlf",
"i18nFormat": "xlf",
"i18nLocale": "de"
},
"de-test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"localize": [
"de"
],
"aot": true,
"i18nFile": "src/locale/messages.de.xlf",
"i18nFormat": "xlf",
"i18nLocale": "de"
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "webadmin:build"
},
"configurations": {
"production": {
"browserTarget": "webadmin:build:production"
},
"local": {
"browserTarget": "webadmin:build:local"
},
"fr": {
"browserTarget": "webadmin:build:fr",
"aot": true
},
"de": {
"browserTarget": "webadmin:build:de"
},
"de-int": {
"browserTarget": "webadmin:build:de-int"
},
"de-test": {
"browserTarget": "webadmin:build:de-test"
}
}
}
}
}
},
"defaultProject": "webadmin",
"cli": {
"analytics": "9009c4ee-47f2-453c-af4a"
}
}
您需要使用 build
和 serve
目标定义一个 extract-i18n
长边目标:
"build": {
...
},
"serve": {
...
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "webadmin:build"
}
}