2018-05-31 11:12:15 -05:00
|
|
|
import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
|
2017-06-16 07:32:15 -05:00
|
|
|
import { BrowserModule } from '@angular/platform-browser'
|
2018-03-22 08:13:30 -05:00
|
|
|
import { ServerService } from '@app/core'
|
2018-01-30 06:27:07 -06:00
|
|
|
import { ResetPasswordModule } from '@app/reset-password'
|
2016-09-06 15:40:57 -05:00
|
|
|
|
2018-01-30 06:27:07 -06:00
|
|
|
import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
|
2018-05-29 04:40:46 -05:00
|
|
|
import { ClipboardModule } from 'ngx-clipboard'
|
2018-09-08 07:34:32 -05:00
|
|
|
import 'focus-visible'
|
2018-01-30 06:27:07 -06:00
|
|
|
|
2017-06-16 07:32:15 -05:00
|
|
|
import { AppRoutingModule } from './app-routing.module'
|
|
|
|
import { AppComponent } from './app.component'
|
|
|
|
import { CoreModule } from './core'
|
2018-01-30 06:27:07 -06:00
|
|
|
import { HeaderComponent } from './header'
|
2017-06-16 07:32:15 -05:00
|
|
|
import { LoginModule } from './login'
|
2018-01-30 06:27:07 -06:00
|
|
|
import { MenuComponent } from './menu'
|
2017-06-16 07:32:15 -05:00
|
|
|
import { SharedModule } from './shared'
|
2018-01-30 06:27:07 -06:00
|
|
|
import { SignupModule } from './signup'
|
2017-06-16 07:32:15 -05:00
|
|
|
import { VideosModule } from './videos'
|
2018-06-18 02:28:08 -05:00
|
|
|
import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n'
|
2018-06-06 10:37:13 -05:00
|
|
|
import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
|
2018-06-28 06:59:48 -05:00
|
|
|
import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
|
2018-07-19 09:17:54 -05:00
|
|
|
import { SearchModule } from '@app/search'
|
2016-11-20 10:18:15 -06:00
|
|
|
|
2018-03-22 08:13:30 -05:00
|
|
|
export function metaFactory (serverService: ServerService): MetaLoader {
|
2017-03-10 03:33:36 -06:00
|
|
|
return new MetaStaticLoader({
|
|
|
|
pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
|
|
|
|
pageTitleSeparator: ' - ',
|
2018-03-22 08:13:30 -05:00
|
|
|
get applicationName () { return serverService.getConfig().instance.name },
|
2017-03-10 03:33:36 -06:00
|
|
|
defaults: {
|
2018-03-22 08:13:30 -05:00
|
|
|
get title () { return serverService.getConfig().instance.name },
|
|
|
|
get description () { return serverService.getConfig().instance.shortDescription }
|
2017-03-10 03:33:36 -06:00
|
|
|
}
|
2017-06-16 07:32:15 -05:00
|
|
|
})
|
2017-03-10 03:33:36 -06:00
|
|
|
}
|
2016-11-04 11:25:26 -05:00
|
|
|
|
2016-09-06 15:40:57 -05:00
|
|
|
@NgModule({
|
|
|
|
bootstrap: [ AppComponent ],
|
|
|
|
declarations: [
|
2017-12-01 02:20:19 -06:00
|
|
|
AppComponent,
|
|
|
|
|
|
|
|
MenuComponent,
|
2018-06-28 06:59:48 -05:00
|
|
|
LanguageChooserComponent,
|
2017-12-05 10:46:33 -06:00
|
|
|
HeaderComponent
|
2016-09-06 15:40:57 -05:00
|
|
|
],
|
2016-11-20 10:18:15 -06:00
|
|
|
imports: [
|
2016-09-06 15:40:57 -05:00
|
|
|
BrowserModule,
|
2018-05-29 04:40:46 -05:00
|
|
|
// FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
|
|
|
|
ClipboardModule,
|
2016-09-09 15:23:41 -05:00
|
|
|
|
2016-11-20 10:18:15 -06:00
|
|
|
CoreModule,
|
|
|
|
SharedModule,
|
|
|
|
|
|
|
|
CoreModule,
|
|
|
|
LoginModule,
|
2018-01-30 06:27:07 -06:00
|
|
|
ResetPasswordModule,
|
2017-04-10 13:29:33 -05:00
|
|
|
SignupModule,
|
2018-07-19 09:17:54 -05:00
|
|
|
SearchModule,
|
2016-11-20 10:18:15 -06:00
|
|
|
SharedModule,
|
2017-03-12 12:40:05 -05:00
|
|
|
VideosModule,
|
|
|
|
|
|
|
|
MetaModule.forRoot({
|
|
|
|
provide: MetaLoader,
|
2018-03-22 08:13:30 -05:00
|
|
|
useFactory: (metaFactory),
|
|
|
|
deps: [ ServerService ]
|
2018-05-31 04:35:01 -05:00
|
|
|
}),
|
|
|
|
|
2018-05-31 07:43:48 -05:00
|
|
|
AppRoutingModule // Put it after all the module because it has the 404 route
|
2016-09-06 15:40:57 -05:00
|
|
|
],
|
2018-05-31 11:12:15 -05:00
|
|
|
providers: [
|
|
|
|
{
|
|
|
|
provide: TRANSLATIONS,
|
2018-10-18 02:08:59 -05:00
|
|
|
useFactory: (locale: string) => {
|
2018-06-06 10:37:13 -05:00
|
|
|
// On dev mode, test localization
|
|
|
|
if (isOnDevLocale()) {
|
2018-08-16 04:48:48 -05:00
|
|
|
locale = buildFileLocale(getDevLocale())
|
2018-06-06 10:37:13 -05:00
|
|
|
return require(`raw-loader!../locale/target/angular_${locale}.xml`)
|
2018-06-05 08:01:45 -05:00
|
|
|
}
|
|
|
|
|
2018-05-31 11:12:15 -05:00
|
|
|
// Default locale, nothing to translate
|
2018-06-06 10:37:13 -05:00
|
|
|
const completeLocale = getCompleteLocale(locale)
|
|
|
|
if (isDefaultLocale(completeLocale)) return ''
|
2018-05-31 11:12:15 -05:00
|
|
|
|
2018-06-06 10:37:13 -05:00
|
|
|
const fileLocale = buildFileLocale(locale)
|
2018-06-06 07:33:21 -05:00
|
|
|
return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`)
|
2018-05-31 11:12:15 -05:00
|
|
|
},
|
|
|
|
deps: [ LOCALE_ID ]
|
|
|
|
},
|
|
|
|
{ provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
|
|
|
|
]
|
2016-09-06 15:40:57 -05:00
|
|
|
})
|
2017-12-11 10:36:46 -06:00
|
|
|
export class AppModule {}
|