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'
6 import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
7 import { ClipboardModule } from 'ngx-clipboard'
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'
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 },
28 get title () { return serverService.getConfig().instance.name },
29 get description () { return serverService.getConfig().instance.shortDescription }
35 bootstrap: [ AppComponent ],
40 LanguageChooserComponent,
41 AvatarNotificationComponent,
46 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
61 useFactory: (metaFactory),
62 deps: [ ServerService ]
65 AppRoutingModule // Put it after all the module because it has the 404 route
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`)
77 // Default locale, nothing to translate
78 const completeLocale = getCompleteLocale(locale)
79 if (isDefaultLocale(completeLocale)) return ''
81 const fileLocale = buildFileLocale(locale)
82 return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`)
86 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
89 export class AppModule {}