]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/app.module.ts
add the comment from https://github.com/Chocobozzz/PeerTube/pull/617/files#diff-5003d...
[github/Chocobozzz/PeerTube.git] / client / src / app / app.module.ts
... / ...
CommitLineData
1import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
2import { BrowserModule } from '@angular/platform-browser'
3import { AboutModule } from '@app/about'
4import { ServerService } from '@app/core'
5import { ResetPasswordModule } from '@app/reset-password'
6
7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
8import { ClipboardModule } from 'ngx-clipboard'
9
10import { AppRoutingModule } from './app-routing.module'
11import { AppComponent } from './app.component'
12import { CoreModule } from './core'
13import { HeaderComponent } from './header'
14import { LoginModule } from './login'
15import { MenuComponent } from './menu'
16import { SharedModule } from './shared'
17import { SignupModule } from './signup'
18import { VideosModule } from './videos'
19import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n'
20
21export 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 AboutModule,
56
57 MetaModule.forRoot({
58 provide: MetaLoader,
59 useFactory: (metaFactory),
60 deps: [ ServerService ]
61 }),
62
63 AppRoutingModule // Put it after all the module because it has the 404 route
64 ],
65 providers: [
66 {
67 provide: TRANSLATIONS,
68 useFactory: (locale) => {
69 const fileLocale = buildFileLocale(locale)
70
71 // Default locale, nothing to translate
72 const defaultFileLocale = buildFileLocale(getDefaultLocale())
73 if (fileLocale === defaultFileLocale) return ''
74
75 return require(`raw-loader!../locale/target/messages_${fileLocale}.xml`)
76 },
77 deps: [ LOCALE_ID ]
78 },
79 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
80 ]
81})
82export class AppModule {}