简体   繁体   中英

Internationalization in angular 2

Im creation a basic web page in angular2 and im implementing internationalization using I18N im exactly following the steps in https://angular.io/docs/ts/latest/cookbook/i18n.html

the command

./node_modules/.bin/ng-xi18n

is not working, i've also tried adding ng-x18n to scripts in package.json ,still not working im getting an error like this:

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

the extraction seems to be failing what to do..please help

It might be already late but, but I had also this problem with the commands.

I use: ./node_modules/.bin/ng-xi18n -p src/tsconfig.json --i18nFormat=xlf or to make it short I added this line "i18n": "ng-xi18n -p src/tsconfig.json --i18nFormat=xlf" to my package.json "scripts" and then I can simply run npm run i18n .

Also the command ng xi18n --output-path=src/locale works for me

Refer to this post as it has good answers and I got it working following it: Angular2 and webpack - i18n plugin vs ng2-translate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM