34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
|
import { Component } from '@angular/core';
|
|
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
|
|
import { componentWrapperDecorator, moduleMetadata } from '@storybook/angular';
|
|
import { TranslateHttpLoaderFactory } from '../src/app/shared/factories';
|
|
|
|
@Component({
|
|
selector: 'storybook-translate',
|
|
template: `<ng-content></ng-content>`,
|
|
})
|
|
class StorybookTranslateComponent {
|
|
constructor(translateService: TranslateService) {
|
|
translateService.setDefaultLang('ru');
|
|
translateService.use('ru');
|
|
}
|
|
}
|
|
|
|
export const translationsDecorators = [
|
|
moduleMetadata({
|
|
declarations: [StorybookTranslateComponent],
|
|
imports: [
|
|
HttpClientModule,
|
|
TranslateModule.forRoot({
|
|
loader: {
|
|
provide: TranslateLoader,
|
|
useFactory: TranslateHttpLoaderFactory,
|
|
deps: [HttpClient],
|
|
},
|
|
}),
|
|
],
|
|
}),
|
|
componentWrapperDecorator(StorybookTranslateComponent),
|
|
];
|