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'
9 import { AppRoutingModule } from './app-routing.module'
10 import { AppComponent } from './app.component'
11 import { CoreModule } from './core'
12 import { HeaderComponent } from './header'
13 import { LoginModule } from './login'
14 import { MenuComponent } from './menu'
15 import { SharedModule } from './shared'
16 import { SignupModule } from './signup'
17 import { VideosModule } from './videos'
18 import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n'
19 import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
21 export function metaFactory (serverService: ServerService): MetaLoader {
22 return new MetaStaticLoader({
23 pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
24 pageTitleSeparator: ' - ',
25 get applicationName () { return serverService.getConfig().instance.name },
27 get title () { return serverService.getConfig().instance.name },
28 get description () { return serverService.getConfig().instance.shortDescription }
34 bootstrap: [ AppComponent ],
43 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
58 useFactory: (metaFactory),
59 deps: [ ServerService ]
62 AppRoutingModule // Put it after all the module because it has the 404 route
66 provide: TRANSLATIONS,
67 useFactory: (locale) => {
68 // On dev mode, test localization
69 if (isOnDevLocale()) {
70 locale = getDevLocale()
71 return require(`raw-loader!../locale/target/angular_${locale}.xml`)
74 // Default locale, nothing to translate
75 const completeLocale = getCompleteLocale(locale)
76 if (isDefaultLocale(completeLocale)) return ''
78 const fileLocale = buildFileLocale(locale)
79 return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`)
83 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
86 export class AppModule {}