Last active
July 21, 2021 22:01
-
-
Save yigitfindikli/301ef5b0853619e360077194bcca755f to your computer and use it in GitHub Desktop.
PrimeNG I18N API 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 { HttpClient, HttpClientModule } from '@angular/common/http'; | |
import { NgModule } from '@angular/core'; | |
import { FormsModule } from '@angular/forms'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | |
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; | |
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; | |
import { RadioButtonModule } from 'primeng/radiobutton'; | |
import { CalendarModule } from 'primeng/calendar'; | |
import { DropdownModule } from 'primeng/dropdown'; | |
import { FileUploadModule } from 'primeng/fileupload'; | |
import { TableModule } from 'primeng/table'; | |
import { ButtonModule } from 'primeng/button'; | |
import { ConfirmPopupModule } from 'primeng/confirmpopup'; | |
import { AppComponent } from './app.component'; | |
// AoT requires an exported function for factories | |
export function HttpLoaderFactory(httpClient: HttpClient) { | |
return new TranslateHttpLoader(httpClient); | |
} | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
BrowserModule, | |
BrowserAnimationsModule, | |
HttpClientModule, | |
FormsModule, | |
RadioButtonModule, | |
DropdownModule, | |
CalendarModule, | |
FileUploadModule, | |
TableModule, | |
ConfirmPopupModule, | |
ButtonModule, | |
TranslateModule.forRoot({ | |
loader: { | |
provide: TranslateLoader, | |
useFactory: HttpLoaderFactory, | |
deps: [HttpClient] | |
} | |
}) | |
], | |
providers: [], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment