mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
16 lines
522 B
TypeScript
16 lines
522 B
TypeScript
import { HttpClient } from '@angular/common/http';
|
|
import { TranslateLoader } from '@ngx-translate/core';
|
|
import { map } from 'rxjs/operators';
|
|
import JSON5 from 'json5'
|
|
|
|
export class TranslateJson5HttpLoader implements TranslateLoader {
|
|
constructor(private http: HttpClient, public prefix?: string, public suffix?: string) {
|
|
}
|
|
|
|
getTranslation(lang: string): any {
|
|
return this.http.get('' + this.prefix + lang + this.suffix, {responseType: 'text'}).pipe(
|
|
map((json: any) => JSON5.parse(json))
|
|
);
|
|
}
|
|
}
|