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'
6 import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
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 import { CustomModalComponent } from '@app/modal/custom-modal.component'
25 export function metaFactory (serverService: ServerService): MetaLoader {
26 return new MetaStaticLoader({
27 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
28 pageTitleSeparator: ' - ',
29 get applicationName () { return serverService.getTmpConfig().instance.name },
31 get title () { return serverService.getTmpConfig().instance.name },
32 get description () { return serverService.getTmpConfig().instance.shortDescription }
38 bootstrap: [ AppComponent ],
43 LanguageChooserComponent,
44 QuickSettingsModalComponent,
45 AvatarNotificationComponent,
47 SearchTypeaheadComponent,
52 WelcomeModalComponent,
53 InstanceConfigWarningModalComponent
70 useFactory: (metaFactory),
71 deps: [ ServerService ]
74 AppRoutingModule // Put it after all the module because it has the 404 route
79 provide: APP_BASE_HREF,
84 provide: TRANSLATIONS,
85 useFactory: (locale: string) => {
86 // Default locale, nothing to translate
87 const completeLocale = getCompleteLocale(locale)
88 if (isDefaultLocale(completeLocale)) return ''
90 const fileLocale = buildFileLocale(locale)
91 return require(`raw-loader!../locale/angular.${fileLocale}.xlf`).default
95 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
98 export class AppModule {}