]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.module.ts
Create webtorrent client on player load
[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'
36f9424f 3import { AboutModule } from '@app/about'
63ac2857 4import { ServerService } from '@app/core'
ecb4e35f 5import { ResetPasswordModule } from '@app/reset-password'
ab32b0fc 6
ecb4e35f 7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
230de99e 8import { ClipboardModule } from 'ngx-clipboard'
ecb4e35f 9
df98563e
C
10import { AppRoutingModule } from './app-routing.module'
11import { AppComponent } from './app.component'
df98563e 12import { CoreModule } from './core'
ecb4e35f 13import { HeaderComponent } from './header'
df98563e 14import { LoginModule } from './login'
ecb4e35f 15import { MenuComponent } from './menu'
df98563e 16import { SharedModule } from './shared'
ecb4e35f 17import { SignupModule } from './signup'
df98563e 18import { VideosModule } from './videos'
b7f1747d 19import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n'
74b7c6d4 20import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
693b1aba 21
63ac2857 22export function metaFactory (serverService: ServerService): MetaLoader {
758b996d
C
23 return new MetaStaticLoader({
24 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
25 pageTitleSeparator: ' - ',
63ac2857 26 get applicationName () { return serverService.getConfig().instance.name },
758b996d 27 defaults: {
63ac2857
C
28 get title () { return serverService.getConfig().instance.name },
29 get description () { return serverService.getConfig().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,
f3aaa9a9 40 HeaderComponent
ab32b0fc 41 ],
693b1aba 42 imports: [
ab32b0fc 43 BrowserModule,
230de99e
C
44 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
45 ClipboardModule,
23bcf666 46
693b1aba
C
47 CoreModule,
48 SharedModule,
49
693b1aba
C
50 CoreModule,
51 LoginModule,
ecb4e35f 52 ResetPasswordModule,
a184c71b 53 SignupModule,
693b1aba 54 SharedModule,
55b33946 55 VideosModule,
36f9424f 56 AboutModule,
55b33946
C
57
58 MetaModule.forRoot({
59 provide: MetaLoader,
63ac2857
C
60 useFactory: (metaFactory),
61 deps: [ ServerService ]
a51bad1a
C
62 }),
63
a9614776 64 AppRoutingModule // Put it after all the module because it has the 404 route
ab32b0fc 65 ],
989e526a
C
66 providers: [
67 {
68 provide: TRANSLATIONS,
69 useFactory: (locale) => {
74b7c6d4
C
70 // On dev mode, test localization
71 if (isOnDevLocale()) {
72 locale = getDevLocale()
73 return require(`raw-loader!../locale/target/angular_${locale}.xml`)
e309822b
C
74 }
75
989e526a 76 // Default locale, nothing to translate
74b7c6d4
C
77 const completeLocale = getCompleteLocale(locale)
78 if (isDefaultLocale(completeLocale)) return ''
989e526a 79
74b7c6d4 80 const fileLocale = buildFileLocale(locale)
f07d6385 81 return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`)
989e526a
C
82 },
83 deps: [ LOCALE_ID ]
84 },
85 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
86 ]
ab32b0fc 87})
63c4db6d 88export class AppModule {}