简体   繁体   English

Angular2 ng-xi18n:不起作用

[英]Angular2 ng-xi18n: Does not work

I tried many solution tips for using ng-xi18n. 我尝试了很多使用ng-xi18n的解决方案提示。

the steps I have done was to uninstall/remove node_modules and installed angular-cli again with npm install --save @angular/cli. 我所做的步骤是卸载/删除node_modules并使用npm install再次安装angular-cli --save @ angular / cli。 and with the last step npm install to get the dependencies. 并使用最后一步npm install来获取依赖项。

But everytime I execute npm run i18n I get an error. 但每次我执行npm run i18n我都会收到错误。

package.json: 的package.json:

{
    ...
    "i18n": "ng-xi18n --i18nFormat=xmb",
    ...
  },
  "devDependencies": {
    "@angular/cli": "^1.0.0-rc.4",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
     ...
    "tslint": "~4.5.0",
    "typescript": "^2.0.0"
  }
}

ng --version: ng --version:

@angular/cli: 1.0.0-rc.4 node: 7.7.3 @angular / cli:1.0.0-rc.4节点:7.7.3

My error: 我的错误:

Error: Error encountered resolving symbol values statically. 错误:静态解析符号值时遇到错误。 Expression form not supported .. resolving symbol AppModule in ode_modules/@angular/cli/blueprints/ng/files/ path /app/app.module.ts 表达形式不受支持..在ode_modules / @ angular / cli / blueprints / ng / files / path /app/app.module.ts中解析符号AppModule

I hope someone experienced the same problem and can help me. 我希望有人遇到同样的问题,可以帮助我。

Thx. 谢谢。

I'm not sure if this will solve your problem, but I had a similar error and needed to point ng-xi18n to my tsconfig.json file. 我不确定这是否能解决您的问题,但我遇到了类似的错误,需要将ng-xi18n指向我的tsconfig.json文件。 In my case I needed to run: 在我的情况下,我需要运行:

./node_modules/.bin/ng-xi18n -p src/tsconfig.json

You might need to change your package.json file 您可能需要更改package.json文件

{
    ...
    "i18n": "ng-xi18n --i18nFormat=xmb -p path/to/tsconfig.json",
    ...
},

https://angular.io/docs/ts/latest/cookbook/i18n.html#!#other-options https://angular.io/docs/ts/latest/cookbook/i18n.html#!#other-options

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Angular 2 ng-xi18n工具翻译属性 - How to translate attributes with the Angular 2 ng-xi18n tool 角单元测试中的模拟管道破坏了ng-xi18n命令 - Mock Pipe in Angular Unit Test breaks ng-xi18n command 如何在没有TypeError的情况下执行ng-xi18n:无法读取undefined的属性'create'? - How to execute ng-xi18n without TypeError: Cannot read property 'create' of undefined? 未知的编译器选项'文件'启动./node_modules/.bin/ng-xi18n - Unknown compiler option 'files' launching ./node_modules/.bin/ng-xi18n 无法提取ng-xi18n ENOENT:没有此类文件或目录 - Can't extract ng-xi18n ENOENT: no such file or directory ng-xi18n错误:模块'LoginModule'导入了意外的值'ServicesModule' - ng-xi18n Error: Unexpected value 'ServicesModule' imported by the module 'LoginModule' ng-xi18n脚本失败,因为它正在检查scss / sass文件 - ng-xi18n script is failing as it is inspecting scss / sass files 更改语言后,ng-xi18n不会更新所有组件 - ng-xi18n doesn't update all components when language changes 在Angular库上运行ng xi18n以生成messages.xlf会引发错误 - Running ng xi18n to generate messages.xlf on angular library throws error Angular2的国际化(i18n)不适用于不在根项目目录中的templateUrls - Angular2's Internationalization (i18n) does not work with templateUrls not located in the root project directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM