Created
December 8, 2019 08:47
-
-
Save itayod/6838cc125f788171bb70996abdf7c2f1 to your computer and use it in GitHub Desktop.
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
@Injectable({ providedIn: 'root' }) | |
export class HttpLoader implements TranslocoLoader { | |
contructor(private http: HttpClient) {} | |
getTranslation(lang: string, { scope }) { | |
const base = this.http.get(`/assets/i18n/${lang}.json`); | |
if(scope) { | |
return base; | |
} | |
return forkJoin([ | |
base, | |
this.http.get(`/assets/i18n/${lang}.vendor.json`) | |
]).pipe( | |
map(([translation, vendor]) => { | |
return { ...translation, ...vendor } | |
}) | |
) | |
} | |
} | |
export const httpLoader = { | |
provide: TRANSLOCO_LOADER, | |
useClass: HttpLoader | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment