mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-11 13:05:08 +00:00
28 lines
654 B
TypeScript
28 lines
654 B
TypeScript
|
import { Injectable } from '@angular/core';
|
||
|
import { TranslateService } from '@ngx-translate/core';
|
||
|
|
||
|
export interface Locale
|
||
|
{
|
||
|
lang: string;
|
||
|
data: Object;
|
||
|
}
|
||
|
|
||
|
@Injectable()
|
||
|
export class FuseTranslationLoaderService
|
||
|
{
|
||
|
constructor(private translate: TranslateService)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public loadTranslations(...args: Locale[]): void
|
||
|
{
|
||
|
const locales = [...args];
|
||
|
|
||
|
locales.forEach((locale) => {
|
||
|
// use setTranslation() with the third argument set to true
|
||
|
// to append translations instead of replacing them
|
||
|
this.translate.setTranslation(locale.lang, locale.data, true);
|
||
|
});
|
||
|
}
|
||
|
}
|