Reputation: 15702
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)
]..
Above does not work with ng2-final. I get:
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
Implementation should work like before on RC4, e.g.:
<div style="text-transform:none">{{ "§GLOBAL.PHONE_CALL_FREE" | translate }}</div>
Upvotes: 0
Views: 409
Reputation: 15702
1.) Pull 3.1.0 of ng-translate or later where they implemented ng2 AoT compatibility and meta information.
2.) Then Use
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.) If not working, follow up on other steps from this thread:
https://github.com/ocombe/ng2-translate/issues/218
Upvotes: 2