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