我正在关注Ocombe的ng2-translate示例Plunker link。我看到它是System.js的例子
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?我必须在webpack配置文件中提到en.json和fr.json文件路径(path-src / main / app / assets / i18n / .json)?
答案 0 :(得分:0)
嘿,我想你需要将这个功能添加到你的app.module:
export function HttpLoaderFactory(http: Http) {
return new TranslateHttpLoader(http, "assets/i18n/", ".json");
}