【问题标题】:Angular 2 i18n Extraction failed errorAngular 2 i18n 提取失败错误
【发布时间】:2016-09-28 14:20:51
【问题描述】:

我在使用 ng-xi18n 命令时遇到以下问题:

c:\Users\Documents\bptt_webclient>node_modules\.bin\ng-xi18n                                                                                                                    
Error: parameters received {"filePath":"c:/Users/Documents/bptt_webclient/node_modules/@angular/common/src/location/location.d.ts","name":"Location"} which is not a StaticSymbo
l                                                                                                                                                                                              
    at StaticReflector.parameters (c:\Users\Documents\bptt_webclient\node_modules\@angular\compiler-cli\src\static_reflector.js:92:19)                                          
    at CompileMetadataResolver.getDependenciesMetadata (c:\Users\Documents\bptt_webclient\node_modules\@angular\compiler\bundles\compiler.umd.js:14317:56)                      
    at CompileMetadataResolver.getTypeMetadata (c:\Users\Documents\bptt_webclient\node_modules\@angular\compiler\bundles\compiler.umd.js:14282:28)                              
    at c:\Users\Documents\bptt_webclient\node_modules\@angular\compiler\bundles\compiler.umd.js:14425:43                                                                        
    at Array.forEach (native)                                                                                                                                                                  
    at CompileMetadataResolver.getProvidersMetadata (c:\Users\Documents\bptt_webclient\node_modules\@angular\compiler\bundles\compiler.umd.js:14405:21)                         
    at c:\Users\Documents\bptt_webclient\node_modules\@angular\compiler\bundles\compiler.umd.js:14412:43                                                                        
    at Array.forEach (native)                                                                                                                                                                  
    at CompileMetadataResolver.getProvidersMetadata (c:\Users\Documents\bptt_webclient\node_modules\@angular\compiler\bundles\compiler.umd.js:14405:21)                         
    at CompileMetadataResolver.getNgModuleMetadata (c:\Users\Documents\bptt_webclient\node_modules\@angular\compiler\bundles\compiler.umd.js:14164:60)                          
Extraction failed  

有人知道如何解决这个问题吗?

节点版本:v6.6.0

角度:2.0.0

感谢您的时间和帮助:)

编辑:对我有用的是取消注释这些行,这会在 static.reflector.js 中引发错误。仍然有错误,而且还有一个新的.xlf 文件。只是一个临时解决方案。

【问题讨论】:

    标签: angular internationalization translation


    【解决方案1】:

    删除RouterTestingModule 的所有导入并等待修复以下问题。

    https://github.com/angular/angular/issues/11276

    【讨论】:

    • 删除RouterTestingModule 后,我遇到了另一个来自primeng/datatables 的错误,可能是因为它还没有准备好AOT。 AOT好像很不稳定……
    • 是的,primeng 还不兼容 AOT:github.com/primefaces/primeng/pull/1004 我暂时删除了所有primeng 组件...
    【解决方案2】:

    尝试使用node_modules/.bin/ng-xi18n -p src/tsconfig.json 中提到的node_modules/.bin/ng-xi18n -p src/tsconfig.json...它会为我生成.xlf 而不会出现任何错误。

    【讨论】:

    • 你解决了吗?我现在遇到了同样的问题
    • 我也面临同样的问题! :)
    【解决方案3】:

    您可以尝试在您的 package.json 中创建一个脚本吗??

    package.json

    {
      ...,
      "scripts": {
        "i18n": "ng-xi18n",
        ...
      },
      ...
    }
    

    然后从命令行

    运行脚本
    $ npm run i18n
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-10
      • 1970-01-01
      • 2019-12-07
      • 1970-01-01
      • 2015-07-16
      • 1970-01-01
      • 2021-03-20
      相关资源
      最近更新 更多