Skip to content

Instantly share code, notes, and snippets.

@ppowstanski
Created March 7, 2022 19:37
Show Gist options
  • Select an option

  • Save ppowstanski/0ce0059100e609f389e51f70820dc2ee to your computer and use it in GitHub Desktop.

Select an option

Save ppowstanski/0ce0059100e609f389e51f70820dc2ee to your computer and use it in GitHub Desktop.
export class TranslationLoaderService extends TranslateLoader {
constructor(private http: HttpClient, private moduleName: string) {
super();
}
getTranslation(lang: string): Observable<any> {
return forkJoin({
moduleTranslation: this.http.get(`/assets/i18n/${moduleName}/${lang}.json`),
commonTranslation: this.http.get(`/assets/i18n/commons/${lang}.json`))
}).pipe(
map((translation: { moduleTranslation: any, commonTranslation: any }) => Object.assign(
{},
translation.commonTranslation,
translation.moduleTranslation
))
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment