2017-03-22 63 views
1

我嘗試了許多使用ng-xi18n的解決方案。Angular2 ng-xi18n:不起作用

我已經完成的步驟是卸載/刪除node_modules並使用npm install --save @ angular/cli再次安裝angular-cli。並用最後一步npm安裝來獲得依賴關係。

但是每次我執行npm run i18n,我都會收到一個錯誤。

的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" 
    } 
} 

納克--version:

@角/ CLI:1.0.0-rc.4 節點:7.7.3

我的錯誤:

錯誤:遇到的錯誤靜態解析符號值。不支持的表現形式..解決ode_modules符號的AppModule/@角/ CLI /藍圖/ NG /文件/ 路徑 /app/app.module.ts

我希望有人經歷了同樣的問題,可以幫助我。

Thx。

回答

0

我不確定這是否能解決您的問題,但我有類似的錯誤,需要將ng-xi18n指向我的tsconfig.json文件。在我來說,我需要運行:

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

您可能需要改變你的package.json文件

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

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

0

THX給了一個建議,但我已經測試了它與您的建議,但沒有運氣。我反而使用ngx-translate,這也很舒服。