]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/app.module.ts
Improve P2P & Privacy section
[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 { ClipboardModule } from 'ngx-clipboard'
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 { MenuComponent } from './menu'
15 import { SharedModule } from './shared'
16 import { SignupModule } from './signup'
17 import { VideosModule } from './videos'
18 import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n'
19 import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
20
21 export function metaFactory (serverService: ServerService): MetaLoader {
22 return new MetaStaticLoader({
23 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
24 pageTitleSeparator: ' - ',
25 get applicationName () { return serverService.getConfig().instance.name },
26 defaults: {
27 get title () { return serverService.getConfig().instance.name },
28 get description () { return serverService.getConfig().instance.shortDescription }
29 }
30 })
31 }
32
33 @NgModule({
34 bootstrap: [ AppComponent ],
35 declarations: [
36 AppComponent,
37
38 MenuComponent,
39 HeaderComponent
40 ],
41 imports: [
42 BrowserModule,
43 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
44 ClipboardModule,
45
46 CoreModule,
47 SharedModule,
48
49 CoreModule,
50 LoginModule,
51 ResetPasswordModule,
52 SignupModule,
53 SharedModule,
54 VideosModule,
55
56 MetaModule.forRoot({
57 provide: MetaLoader,
58 useFactory: (metaFactory),
59 deps: [ ServerService ]
60 }),
61
62 AppRoutingModule // Put it after all the module because it has the 404 route
63 ],
64 providers: [
65 {
66 provide: TRANSLATIONS,
67 useFactory: (locale) => {
68 // On dev mode, test localization
69 if (isOnDevLocale()) {
70 locale = getDevLocale()
71 return require(`raw-loader!../locale/target/angular_${locale}.xml`)
72 }
73
74 // Default locale, nothing to translate
75 const completeLocale = getCompleteLocale(locale)
76 if (isDefaultLocale(completeLocale)) return ''
77
78 const fileLocale = buildFileLocale(locale)
79 return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`)
80 },
81 deps: [ LOCALE_ID ]
82 },
83 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
84 ]
85 })
86 export class AppModule {}