import { Provider } from '@angular/core';
import { TranslateLoader } from '@ngx-translate/core';
import { HttpBackend } from '@angular/common/http';
import { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
import { ENVIRONMENT_TOKEN, IENVIRONMENT } from '../../injection-tokens';



export function HttpLoaderFactory(_httpBackend: HttpBackend, environment: IENVIRONMENT): TranslateLoader {
  return new MultiTranslateHttpLoader(_httpBackend, [
    { prefix: './assets/translate-core/', suffix: '.json' },
    { prefix: environment.translationFolder, suffix: '.json' },
  ]
  );
}


export const TranslateLoaderProvider: Provider = {
  provide: TranslateLoader,
  useFactory: HttpLoaderFactory,
  deps: [HttpBackend, ENVIRONMENT_TOKEN],
};
