Use po files with ngx-translate
Go to file
Vasiliy Tolstov bf0dd0cf00 update all
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2022-06-26 14:44:03 +03:00
dist initial import 2022-04-25 18:42:42 +03:00
src initial import 2022-04-25 18:42:42 +03:00
.gitignore initial import 2022-04-25 18:42:42 +03:00
package-lock.json update all 2022-06-26 14:44:03 +03:00
package.json update all 2022-06-26 14:44:03 +03:00
README.md initial import 2022-04-25 18:42:42 +03:00
tsconfig.json initial import 2022-04-25 18:42:42 +03:00
tslint.json initial import 2022-04-25 18:42:42 +03:00

Description

Load po files for use with ngx-translate

Installation:

npm i @ngx-translate/core --save
npm i @unistack-org/ngx-translate-po-http-loader --save

Usage:

import { HttpClient, HttpClientModule } from '@angular/common/http';

import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslatePoHttpLoader } from '@unistack-org/ngx-translate-po-http-loader';

export function createTranslateLoader(http: HttpClient) {
	return new TranslatePoHttpLoader(http, 'assets/i18n', '.po');
}

@NgModule({
	imports: [
		BrowserModule,
		HttpClientModule,
		TranslateModule.forRoot({
			loader: {
				provide: TranslateLoader,
				useFactory: createTranslateLoader,
				deps: [HttpClient]
			}
		})
	],
	bootstrap: [AppComponent]
})
export class AppModule { }