Last active
July 27, 2020 15:13
Translation and globalization in Ionic 5 - Translation with ngx-translate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { IonicModule } from '@ionic/angular'; | |
import { NgModule } from '@angular/core'; | |
import { CommonModule } from '@angular/common'; | |
import { FormsModule } from '@angular/forms'; | |
import { Tab1Page } from './tab1.page'; | |
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module'; | |
import { Tab1PageRoutingModule } from './tab1-routing.module'; | |
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; | |
export function HttpLoaderFactory(http: HttpClient) { | |
return new TranslateHttpLoader(http, "./assets/i18n/", ".json"); | |
} | |
@NgModule({ | |
imports: [ | |
IonicModule, | |
TranslateModule.forChild({ | |
loader: { | |
provide: TranslateLoader, | |
useFactory: HttpLoaderFactory, | |
deps: [HttpClient] | |
} | |
}), | |
CommonModule, | |
FormsModule, | |
ExploreContainerComponentModule, | |
Tab1PageRoutingModule | |
], | |
declarations: [Tab1Page] | |
}) | |
export class Tab1PageModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment