]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/app.module.ts
d11dba34d3febf4150b5bca3e1af1f3116835949
[github/Chocobozzz/PeerTube.git] / client / src / app / app.module.ts
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 } 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
23 export function metaFactory (serverService: ServerService): MetaLoader {
24 return new MetaStaticLoader({
25 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
26 pageTitleSeparator: ' - ',
27 get applicationName () { return serverService.getTmpConfig().instance.name },
28 defaults: {
29 get title () { return serverService.getTmpConfig().instance.name },
30 get description () { return serverService.getTmpConfig().instance.shortDescription }
31 }
32 })
33 }
34
35 @NgModule({
36 bootstrap: [ AppComponent ],
37 declarations: [
38 AppComponent,
39
40 MenuComponent,
41 LanguageChooserComponent,
42 AvatarNotificationComponent,
43 HeaderComponent,
44
45 WelcomeModalComponent,
46 InstanceConfigWarningModalComponent
47 ],
48 imports: [
49 BrowserModule,
50
51 CoreModule,
52 SharedModule,
53
54 CoreModule,
55 LoginModule,
56 ResetPasswordModule,
57 SearchModule,
58 SharedModule,
59 VideosModule,
60
61 MetaModule.forRoot({
62 provide: MetaLoader,
63 useFactory: (metaFactory),
64 deps: [ ServerService ]
65 }),
66
67 AppRoutingModule // Put it after all the module because it has the 404 route
68 ],
69
70 providers: [
71 {
72 provide: APP_BASE_HREF,
73 useValue: '/'
74 },
75
76 {
77 provide: TRANSLATIONS,
78 useFactory: (locale: string) => {
79 // Default locale, nothing to translate
80 const completeLocale = getCompleteLocale(locale)
81 if (isDefaultLocale(completeLocale)) return ''
82
83 const fileLocale = buildFileLocale(locale)
84 return require(`raw-loader!../locale/angular.${fileLocale}.xlf`)
85 },
86 deps: [ LOCALE_ID ]
87 },
88 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
89 ]
90 })
91 export class AppModule {}