]>
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' |
437e8e06 | 23 | import { CustomModalComponent } from '@app/modal/custom-modal.component' |
693b1aba | 24 | |
63ac2857 | 25 | export function metaFactory (serverService: ServerService): MetaLoader { |
758b996d C |
26 | return new MetaStaticLoader({ |
27 | pageTitlePositioning: PageTitlePositioning.PrependPageTitle, | |
28 | pageTitleSeparator: ' - ', | |
ba430d75 | 29 | get applicationName () { return serverService.getTmpConfig().instance.name }, |
758b996d | 30 | defaults: { |
ba430d75 C |
31 | get title () { return serverService.getTmpConfig().instance.name }, |
32 | get description () { return serverService.getTmpConfig().instance.shortDescription } | |
758b996d | 33 | } |
df98563e | 34 | }) |
758b996d | 35 | } |
b58c69a1 | 36 | |
ab32b0fc C |
37 | @NgModule({ |
38 | bootstrap: [ AppComponent ], | |
39 | declarations: [ | |
b33f657c C |
40 | AppComponent, |
41 | ||
42 | MenuComponent, | |
8afc19a6 | 43 | LanguageChooserComponent, |
d3217560 | 44 | QuickSettingsModalComponent, |
2f1548fd | 45 | AvatarNotificationComponent, |
43d0ea7f | 46 | HeaderComponent, |
f409f0c3 | 47 | SearchTypeaheadComponent, |
6af662a5 RK |
48 | SuggestionsComponent, |
49 | SuggestionComponent, | |
43d0ea7f | 50 | |
437e8e06 | 51 | CustomModalComponent, |
43d0ea7f C |
52 | WelcomeModalComponent, |
53 | InstanceConfigWarningModalComponent | |
ab32b0fc | 54 | ], |
693b1aba | 55 | imports: [ |
ab32b0fc | 56 | BrowserModule, |
23bcf666 | 57 | |
693b1aba C |
58 | CoreModule, |
59 | SharedModule, | |
60 | ||
693b1aba C |
61 | CoreModule, |
62 | LoginModule, | |
ecb4e35f | 63 | ResetPasswordModule, |
57c36b27 | 64 | SearchModule, |
693b1aba | 65 | SharedModule, |
55b33946 C |
66 | VideosModule, |
67 | ||
68 | MetaModule.forRoot({ | |
69 | provide: MetaLoader, | |
63ac2857 C |
70 | useFactory: (metaFactory), |
71 | deps: [ ServerService ] | |
a51bad1a C |
72 | }), |
73 | ||
a9614776 | 74 | AppRoutingModule // Put it after all the module because it has the 404 route |
ab32b0fc | 75 | ], |
361dcebc | 76 | |
989e526a | 77 | providers: [ |
8cc56c7f C |
78 | { |
79 | provide: APP_BASE_HREF, | |
80 | useValue: '/' | |
81 | }, | |
82 | ||
989e526a C |
83 | { |
84 | provide: TRANSLATIONS, | |
244b4ae3 | 85 | useFactory: (locale: string) => { |
1fe654e0 | 86 | // Default locale, nothing to translate |
74b7c6d4 C |
87 | const completeLocale = getCompleteLocale(locale) |
88 | if (isDefaultLocale(completeLocale)) return '' | |
989e526a | 89 | |
74b7c6d4 | 90 | const fileLocale = buildFileLocale(locale) |
1fe654e0 | 91 | return require(`raw-loader!../locale/angular.${fileLocale}.xlf`).default |
989e526a C |
92 | }, |
93 | deps: [ LOCALE_ID ] | |
94 | }, | |
95 | { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' } | |
96 | ] | |
ab32b0fc | 97 | }) |
63c4db6d | 98 | export class AppModule {} |