]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/app.module.ts
Update to angular 9
[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 { ServerService } from '@app/core'
4import { ResetPasswordModule } from '@app/reset-password'
5
6import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
7import { ClipboardModule } from 'ngx-clipboard'
8import 'focus-visible'
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 { AvatarNotificationComponent, LanguageChooserComponent, MenuComponent } from './menu'
16import { SharedModule } from './shared'
17import { VideosModule } from './videos'
18import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n'
19import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
20import { SearchModule } from '@app/search'
21import { WelcomeModalComponent } from '@app/modal/welcome-modal.component'
22import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-warning-modal.component'
23
24export function metaFactory (serverService: ServerService): MetaLoader {
25 return new MetaStaticLoader({
26 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
27 pageTitleSeparator: ' - ',
28 get applicationName () { return serverService.getTmpConfig().instance.name },
29 defaults: {
30 get title () { return serverService.getTmpConfig().instance.name },
31 get description () { return serverService.getTmpConfig().instance.shortDescription }
32 }
33 })
34}
35
36@NgModule({
37 bootstrap: [ AppComponent ],
38 declarations: [
39 AppComponent,
40
41 MenuComponent,
42 LanguageChooserComponent,
43 AvatarNotificationComponent,
44 HeaderComponent,
45
46 WelcomeModalComponent,
47 InstanceConfigWarningModalComponent
48 ],
49 imports: [
50 BrowserModule,
51
52 CoreModule,
53 SharedModule,
54
55 CoreModule,
56 LoginModule,
57 ResetPasswordModule,
58 SearchModule,
59 SharedModule,
60 VideosModule,
61
62 MetaModule.forRoot({
63 provide: MetaLoader,
64 useFactory: (metaFactory),
65 deps: [ ServerService ]
66 }),
67
68 AppRoutingModule // Put it after all the module because it has the 404 route
69 ],
70 providers: [
71 {
72 provide: TRANSLATIONS,
73 useFactory: (locale: string) => {
74 // On dev mode, test localization
75 if (isOnDevLocale()) {
76 locale = buildFileLocale(getDevLocale())
77 return require(`raw-loader!../locale/angular.${locale}.xlf`)
78 }
79
80 // Default locale, nothing to translate
81 const completeLocale = getCompleteLocale(locale)
82 if (isDefaultLocale(completeLocale)) return ''
83
84 const fileLocale = buildFileLocale(locale)
85 return require(`raw-loader!../locale/angular.${fileLocale}.xlf`)
86 },
87 deps: [ LOCALE_ID ]
88 },
89 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
90 ]
91})
92export class AppModule {}