0
我正在關注Ocombe的ng2-translate示例Plunker link。我看到它是System.js的示例如何配置webpack以在Angular2中使用ng2-translate
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',
..........
..........
}
如何配置ng2-translate與webpack?我必須在webpack配置文件中提及en.json和fr.json文件路徑(path-src/main/app/assets/i18n/.json)嗎?
https://github.com/ocombe/ng2-translate#configuration – ranakrunal9
@ ranakrunal9我遵循的例子,但我m得到Json文件未找到404錯誤。我不知道在哪裏需要提及webpack – Protagonist
中的那些文件,在控制檯中檢查URL爲'http:// localhost:3000 /#/ assets/i18n/en.json'的路徑,其中'ng2-translate'服務是檢查文件並確保該文件存在於該位置。正如你使用'webpack'可能你忘了複製那些文件在你建立文件夾。 – ranakrunal9