mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 18:53:29 +00:00
[SM-108] Refactor Reports - Add storybook stories (#3204)
This commit is contained in:
38
apps/web/src/app/tests/preloaded-english-i18n.module.ts
Normal file
38
apps/web/src/app/tests/preloaded-english-i18n.module.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { APP_INITIALIZER, NgModule } from "@angular/core";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { I18nService as BaseI18nService } from "@bitwarden/common/services/i18n.service";
|
||||
|
||||
import * as eng from "../../locales/en/messages.json";
|
||||
|
||||
class PreloadedEnglishI18nService extends BaseI18nService {
|
||||
constructor() {
|
||||
super("en", "", () => {
|
||||
return Promise.resolve(eng);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function i18nInitializer(i18nService: I18nService): () => Promise<void> {
|
||||
return async () => {
|
||||
await (i18nService as any).init();
|
||||
};
|
||||
}
|
||||
|
||||
// This is a helper I18nService implementation that loads the english `message.json` eliminating
|
||||
// the need for fetching them dynamically. It should only be used within storybook.
|
||||
@NgModule({
|
||||
providers: [
|
||||
{
|
||||
provide: I18nService,
|
||||
useClass: PreloadedEnglishI18nService,
|
||||
},
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: i18nInitializer,
|
||||
deps: [I18nService],
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class PreloadedEnglishI18nModule {}
|
||||
Reference in New Issue
Block a user