]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.module.ts
Prepare i18n files
[github/Chocobozzz/PeerTube.git] / client / src / app / app.module.ts
CommitLineData
989e526a 1import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
df98563e 2import { BrowserModule } from '@angular/platform-browser'
36f9424f 3import { AboutModule } from '@app/about'
63ac2857 4import { ServerService } from '@app/core'
ecb4e35f 5import { ResetPasswordModule } from '@app/reset-password'
ab32b0fc 6
ecb4e35f 7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
230de99e 8import { ClipboardModule } from 'ngx-clipboard'
ecb4e35f 9
df98563e
C
10import { AppRoutingModule } from './app-routing.module'
11import { AppComponent } from './app.component'
df98563e 12import { CoreModule } from './core'
ecb4e35f 13import { HeaderComponent } from './header'
df98563e 14import { LoginModule } from './login'
ecb4e35f 15import { MenuComponent } from './menu'
df98563e 16import { SharedModule } from './shared'
ecb4e35f 17import { SignupModule } from './signup'
df98563e 18import { VideosModule } from './videos'
989e526a 19import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n'
693b1aba 20
63ac2857 21export function metaFactory (serverService: ServerService): MetaLoader {
758b996d
C
22 return new MetaStaticLoader({
23 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
24 pageTitleSeparator: ' - ',
63ac2857 25 get applicationName () { return serverService.getConfig().instance.name },
758b996d 26 defaults: {
63ac2857
C
27 get title () { return serverService.getConfig().instance.name },
28 get description () { return serverService.getConfig().instance.shortDescription }
758b996d 29 }
df98563e 30 })
758b996d 31}
b58c69a1 32
ab32b0fc
C
33@NgModule({
34 bootstrap: [ AppComponent ],
35 declarations: [
b33f657c
C
36 AppComponent,
37
38 MenuComponent,
f3aaa9a9 39 HeaderComponent
ab32b0fc 40 ],
693b1aba 41 imports: [
ab32b0fc 42 BrowserModule,
230de99e
C
43 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
44 ClipboardModule,
23bcf666 45
693b1aba
C
46 CoreModule,
47 SharedModule,
48
693b1aba
C
49 CoreModule,
50 LoginModule,
ecb4e35f 51 ResetPasswordModule,
a184c71b 52 SignupModule,
693b1aba 53 SharedModule,
55b33946 54 VideosModule,
36f9424f 55 AboutModule,
55b33946
C
56
57 MetaModule.forRoot({
58 provide: MetaLoader,
63ac2857
C
59 useFactory: (metaFactory),
60 deps: [ ServerService ]
a51bad1a
C
61 }),
62
a9614776 63 AppRoutingModule // Put it after all the module because it has the 404 route
ab32b0fc 64 ],
989e526a
C
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 ]
ab32b0fc 81})
63c4db6d 82export class AppModule {}