]>
Commit | Line | Data |
---|---|---|
1 | import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' | |
2 | import { BrowserModule } from '@angular/platform-browser' | |
3 | import { ServerService } from '@app/core' | |
4 | import { ResetPasswordModule } from '@app/reset-password' | |
5 | ||
6 | import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' | |
7 | import 'focus-visible' | |
8 | ||
9 | import { AppRoutingModule } from './app-routing.module' | |
10 | import { AppComponent } from './app.component' | |
11 | import { CoreModule } from './core' | |
12 | import { HeaderComponent, SearchTypeaheadComponent, SuggestionsComponent, SuggestionComponent } from './header' | |
13 | import { LoginModule } from './login' | |
14 | import { AvatarNotificationComponent, LanguageChooserComponent, MenuComponent } from './menu' | |
15 | import { SharedModule } from './shared' | |
16 | import { VideosModule } from './videos' | |
17 | import { SearchModule } from '@app/search' | |
18 | import { WelcomeModalComponent } from '@app/modal/welcome-modal.component' | |
19 | import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-warning-modal.component' | |
20 | import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/models' | |
21 | import { APP_BASE_HREF } from '@angular/common' | |
22 | import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' | |
23 | ||
24 | export function metaFactory (serverService: ServerService): MetaLoader { | |
25 | return new MetaStaticLoader({ | |
26 | pageTitlePositioning: PageTitlePositioning.PrependPageTitle, | |
27 | pageTitleSeparator: ' - ', | |
28 | get applicationName () { return serverService.getTmpConfig().instance.name }, | |
29 | defaults: { | |
30 | get title () { return serverService.getTmpConfig().instance.name }, | |
31 | get description () { return serverService.getTmpConfig().instance.shortDescription } | |
32 | } | |
33 | }) | |
34 | } | |
35 | ||
36 | @NgModule({ | |
37 | bootstrap: [ AppComponent ], | |
38 | declarations: [ | |
39 | AppComponent, | |
40 | ||
41 | MenuComponent, | |
42 | LanguageChooserComponent, | |
43 | QuickSettingsModalComponent, | |
44 | AvatarNotificationComponent, | |
45 | HeaderComponent, | |
46 | SearchTypeaheadComponent, | |
47 | SuggestionsComponent, | |
48 | SuggestionComponent, | |
49 | ||
50 | WelcomeModalComponent, | |
51 | InstanceConfigWarningModalComponent | |
52 | ], | |
53 | imports: [ | |
54 | BrowserModule, | |
55 | ||
56 | CoreModule, | |
57 | SharedModule, | |
58 | ||
59 | CoreModule, | |
60 | LoginModule, | |
61 | ResetPasswordModule, | |
62 | SearchModule, | |
63 | SharedModule, | |
64 | VideosModule, | |
65 | ||
66 | MetaModule.forRoot({ | |
67 | provide: MetaLoader, | |
68 | useFactory: (metaFactory), | |
69 | deps: [ ServerService ] | |
70 | }), | |
71 | ||
72 | AppRoutingModule // Put it after all the module because it has the 404 route | |
73 | ], | |
74 | ||
75 | providers: [ | |
76 | { | |
77 | provide: APP_BASE_HREF, | |
78 | useValue: '/' | |
79 | }, | |
80 | ||
81 | { | |
82 | provide: TRANSLATIONS, | |
83 | useFactory: (locale: string) => { | |
84 | // Default locale, nothing to translate | |
85 | const completeLocale = getCompleteLocale(locale) | |
86 | if (isDefaultLocale(completeLocale)) return '' | |
87 | ||
88 | const fileLocale = buildFileLocale(locale) | |
89 | return require(`raw-loader!../locale/angular.${fileLocale}.xlf`) | |
90 | }, | |
91 | deps: [ LOCALE_ID ] | |
92 | }, | |
93 | { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' } | |
94 | ] | |
95 | }) | |
96 | export class AppModule {} |