【问题标题】:Internationalization in angular 2Angular 2 中的国际化
【发布时间】:2017-09-16 14:38:21
【问题描述】:

我在 angular2 中创建了一个基本网页,并使用 I18N 实现国际化,我完全按照中的步骤进行操作 https://angular.io/docs/ts/latest/cookbook/i18n.html

命令

./node_modules/.bin/ng-xi18n

不起作用,我也尝试将 ng-x18n 添加到 package.json 中的脚本中,但仍然无法正常工作,我收到如下错误:

Error: Error encountered resolving symbol values statically. Calling function 'NoOpAnimationDriver', function calls are not supported. Consider replacing the function or lambda with a reference to an expo
rted function, resolving symbol AnimationDriver.NOOP in E:/angular/myproject/localetest/node_modules/@angular/platform-browser/src/dom/animation_driver.d.ts, resolving symbol BrowserTestingModule in E:/an
gular/myproject/localetest/node_modules/@angular/platform-browser/testing/browser.d.ts, resolving symbol BrowserTestingModule in E:/angular/myproject/localetest/node_modules/@angular/platform-browser/test
ing/browser.d.ts
    at SyntaxError.BaseError [as constructor] (E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:1597:31)
    at new SyntaxError (E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:1795:20)
    at simplifyInContext (E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:25774:27)
    at StaticReflector.simplify (E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:25786:17)
    at StaticReflector.annotations (E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:25282:64)
    at NgModuleResolver.resolve (E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:17762:86)
    at CompileMetadataResolver.getNgModuleMetadata (E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:18263:64)
    at CompileMetadataResolver.getNgModuleSummary (E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:18219:56)
    at E:\angular\myproject\localetest\node_modules\@angular\compiler\bundles\compiler.umd.js:18309:72
    at Array.forEach (native)
Extraction failed

提取似乎失败了怎么办..请帮助

【问题讨论】:

  • 使用ng2-translate 进行国际化。
  • 现在其实是ngx-translate

标签: javascript angular typescript visual-studio-code angular2-services


【解决方案1】:

可能已经晚了,但是我也遇到了这个命令问题。

我使用:./node_modules/.bin/ng-xi18n -p src/tsconfig.json --i18nFormat=xlf 或者简而言之,我将这一行 "i18n": "ng-xi18n -p src/tsconfig.json --i18nFormat=xlf" 添加到我的 package.json “脚本”中,然后我可以简单地运行 npm run i18n

ng xi18n --output-path=src/locale 命令也适用于我

请参阅这篇文章,因为它有很好的答案,我得到了它的工作:Angular2 and webpack - i18n plugin vs ng2-translate

【讨论】:

  • thanx mate.. 会调查的。
猜你喜欢
  • 1970-01-01
  • 2018-04-29
  • 1970-01-01
  • 1970-01-01
  • 2018-01-18
  • 2012-04-25
  • 2023-01-10
  • 2017-06-09
  • 1970-01-01
相关资源
最近更新 更多