]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/app.module.ts
Fix markdown links truncating
[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, getCompleteLocale, getDefaultLocale, isDefaultLocale } from '../../../shared/models/i18n'
20import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
21
22export 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 HeaderComponent
41 ],
42 imports: [
43 BrowserModule,
44 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
45 ClipboardModule,
46
47 CoreModule,
48 SharedModule,
49
50 CoreModule,
51 LoginModule,
52 ResetPasswordModule,
53 SignupModule,
54 SharedModule,
55 VideosModule,
56 AboutModule,
57
58 MetaModule.forRoot({
59 provide: MetaLoader,
60 useFactory: (metaFactory),
61 deps: [ ServerService ]
62 }),
63
64 AppRoutingModule // Put it after all the module because it has the 404 route
65 ],
66 providers: [
67 {
68 provide: TRANSLATIONS,
69 useFactory: (locale) => {
70 // On dev mode, test localization
71 if (isOnDevLocale()) {
72 locale = getDevLocale()
73 return require(`raw-loader!../locale/target/angular_${locale}.xml`)
74 }
75
76 // Default locale, nothing to translate
77 const completeLocale = getCompleteLocale(locale)
78 if (isDefaultLocale(completeLocale)) return ''
79
80 const fileLocale = buildFileLocale(locale)
81 return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`)
82 },
83 deps: [ LOCALE_ID ]
84 },
85 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
86 ]
87})
88export class AppModule {}