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