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