import {
TranslatePipe,
TranslateModule,
TranslateService,
TranslateLoader,
TranslateStaticLoader,
MissingTranslationHandler
} from "ng2-translate/ng2-translate";
@NgModule({
declarations: [
MyApp
],
imports: [
IonicModule.forRoot(MyApp, {}),
HttpModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (http: Http) => new TranslateStaticLoader(http, "../../www/assets/i18n", ".json"),
deps: [Http]
}),
StoreModule.provideStore(rootReducer)
]..
以上不适用于ng2-final。我明白了:
03:26:44] ngc: Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 98:25 in the original .ts file), resolving symbol AppModule in /Users/me/devel/mega-project/.tmp/app/app.module.ts
实施应该像以前一样在RC4上工作,例如:
<div style="text-transform:none">{{ "§GLOBAL.PHONE_CALL_FREE" | translate }}</div>
答案 0 :(得分:2)
1。)拉动3.1.0的ng-translate或更高版本,实现ng2 AoT兼容性和元信息。
2。)然后使用
import {TranslateModule, TranslateStaticLoader} from "ng2-translate/ng2-translate";
import {TranslateLoader} from "ng2-translate";
export function translateLoaderFactory(http: any) {
return new TranslateStaticLoader(http, './assets/i18n', '.json');
}
@NgModule({
imports: [
IonicModule.forRoot(MyApp),
HttpModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: translateLoaderFactory,
deps: [Http]
}),
3。)如果不能正常工作,请跟进此主题中的其他步骤: