簡體   English   中英

Angle 2的國際化

[英]Internationalization in angular 2

我在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

提取似乎失敗了..請幫助

可能已經晚了,但是我的命令也有這個問題。

我使用: ./node_modules/.bin/ng-xi18n -p src/tsconfig.json --i18nFormat=xlf "i18n": "ng-xi18n -p src/tsconfig.json --i18nFormat=xlf" ./node_modules/.bin/ng-xi18n -p src/tsconfig.json --i18nFormat=xlf或簡而言之,我添加了以下行"i18n": "ng-xi18n -p src/tsconfig.json --i18nFormat=xlf"到我的package.json” scripts“,然后我可以簡單地運行npm run i18n

另外命令ng xi18n --output-path=src/locale適用於我

參考這篇文章,因為它有很好的答案,我可以按照它工作: Angular2和webpack-i18n插件vs ng2-translate

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM