]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/app.module.ts
Translate player according to the interface lang
[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'
8
9import { AppRoutingModule } from './app-routing.module'
10import { AppComponent } from './app.component'
11import { CoreModule } from './core'
12import { HeaderComponent } from './header'
13import { LoginModule } from './login'
14import { MenuComponent } from './menu'
15import { SharedModule } from './shared'
16import { SignupModule } from './signup'
17import { VideosModule } from './videos'
18import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n'
19import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
20import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
21import { SearchModule } from '@app/search'
22
23export function metaFactory (serverService: ServerService): MetaLoader {
24 return new MetaStaticLoader({
25 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
26 pageTitleSeparator: ' - ',
27 get applicationName () { return serverService.getConfig().instance.name },
28 defaults: {
29 get title () { return serverService.getConfig().instance.name },
30 get description () { return serverService.getConfig().instance.shortDescription }
31 }
32 })
33}
34
35@NgModule({
36 bootstrap: [ AppComponent ],
37 declarations: [
38 AppComponent,
39
40 MenuComponent,
41 LanguageChooserComponent,
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 SignupModule,
56 SearchModule,
57 SharedModule,
58 VideosModule,
59
60 MetaModule.forRoot({
61 provide: MetaLoader,
62 useFactory: (metaFactory),
63 deps: [ ServerService ]
64 }),
65
66 AppRoutingModule // Put it after all the module because it has the 404 route
67 ],
68 providers: [
69 {
70 provide: TRANSLATIONS,
71 useFactory: (locale) => {
72 // On dev mode, test localization
73 if (isOnDevLocale()) {
74 locale = getDevLocale()
75 return require(`raw-loader!../locale/target/angular_${locale}.xml`)
76 }
77
78 // Default locale, nothing to translate
79 const completeLocale = getCompleteLocale(locale)
80 if (isDefaultLocale(completeLocale)) return ''
81
82 const fileLocale = buildFileLocale(locale)
83 return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`)
84 },
85 deps: [ LOCALE_ID ]
86 },
87 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
88 ]
89})
90export class AppModule {}