首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Angular2中配置webpack使用ng2-translate

如何在Angular2中配置webpack使用ng2-translate
EN

Stack Overflow用户
提问于 2016-11-17 14:05:10
回答 1查看 434关注 0票数 0

我遵循的是Ocombe的ng2-translate示例Plunker link。我看到这是System.js的例子

代码语言:javascript
复制
System.config({
  //use typescript for compilation
  transpiler: 'typescript',
  //typescript compiler options
  typescriptOptions: {
    emitDecoratorMetadata: true
  },
  paths: {
    'npm:': 'https://unpkg.com/'
  },
  //map tells the System loader where to look for things
  map: {
    'app': "./src",
    'ng2-translate': 'npm:ng2-translate',
    '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
    '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
    '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
    '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
    '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
    '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
     ..........
     ..........

  }

如何使用webpack配置ng2-translate?在哪里我必须提到en.json和fr.json文件的路径(路径-src/main/app/assets/i18n/.json)在webpack配置文件中?

EN

回答 1

Stack Overflow用户

发布于 2017-07-19 18:59:54

嘿,我猜你需要把这个函数添加到你的app.module中:

代码语言:javascript
复制
    export function HttpLoaderFactory(http: Http) {
            return new TranslateHttpLoader(http, "assets/i18n/", ".json");
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40647748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档