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'
8 import { HotkeyModule, IHotkeyOptions } from 'angular2-hotkeys'
11 import { AppRoutingModule } from './app-routing.module'
12 import { AppComponent } from './app.component'
13 import { CoreModule } from './core'
14 import { HeaderComponent } from './header'
15 import { LoginModule } from './login'
16 import { MenuComponent } from './menu'
17 import { SharedModule } from './shared'
18 import { SignupModule } from './signup'
19 import { VideosModule } from './videos'
20 import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n'
21 import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
22 import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
23 import { SearchModule } from '@app/search'
25 export function metaFactory (serverService: ServerService): MetaLoader {
26 return new MetaStaticLoader({
27 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
28 pageTitleSeparator: ' - ',
29 get applicationName () { return serverService.getConfig().instance.name },
31 get title () { return serverService.getConfig().instance.name },
32 get description () { return serverService.getConfig().instance.shortDescription }
38 bootstrap: [ AppComponent ],
43 LanguageChooserComponent,
48 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
50 HotkeyModule.forRoot({
51 cheatSheetCloseEsc: true
67 useFactory: (metaFactory),
68 deps: [ ServerService ]
71 AppRoutingModule // Put it after all the module because it has the 404 route
75 provide: TRANSLATIONS,
76 useFactory: (locale) => {
77 // On dev mode, test localization
78 if (isOnDevLocale()) {
79 locale = buildFileLocale(getDevLocale())
80 return require(`raw-loader!../locale/target/angular_${locale}.xml`)
83 // Default locale, nothing to translate
84 const completeLocale = getCompleteLocale(locale)
85 if (isDefaultLocale(completeLocale)) return ''
87 const fileLocale = buildFileLocale(locale)
88 return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`)
92 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
95 export class AppModule {}