PeerTube/client/src/app/app.module.ts

98 lines
3.2 KiB
TypeScript
Raw Normal View History

2018-05-31 18:12:15 +02:00
import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
2018-03-22 14:13:30 +01:00
import { ServerService } from '@app/core'
2018-01-30 13:27:07 +01:00
import { ResetPasswordModule } from '@app/reset-password'
import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
import 'focus-visible'
2018-01-30 13:27:07 +01:00
import { AppRoutingModule } from './app-routing.module'
import { AppComponent } from './app.component'
import { CoreModule } from './core'
2020-05-29 16:16:24 +02:00
import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header'
import { LoginModule } from './login'
2019-01-08 11:26:41 +01:00
import { AvatarNotificationComponent, LanguageChooserComponent, MenuComponent } from './menu'
import { SharedModule } from './shared'
import { VideosModule } from './videos'
2018-07-19 16:17:54 +02:00
import { SearchModule } from '@app/search'
2019-08-28 14:40:06 +02:00
import { WelcomeModalComponent } from '@app/modal/welcome-modal.component'
import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-warning-modal.component'
2020-02-07 15:51:19 +01:00
import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/models'
import { APP_BASE_HREF, registerLocaleData } from '@angular/common'
import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component'
import { CustomModalComponent } from '@app/modal/custom-modal.component'
import localeOc from '@app/shared/locale/oc'
registerLocaleData(localeOc, 'oc')
2016-11-20 17:18:15 +01:00
2016-09-06 22:40:57 +02:00
@NgModule({
bootstrap: [ AppComponent ],
declarations: [
2017-12-01 09:20:19 +01:00
AppComponent,
MenuComponent,
2018-06-28 13:59:48 +02:00
LanguageChooserComponent,
QuickSettingsModalComponent,
2019-01-08 11:26:41 +01:00
AvatarNotificationComponent,
2019-08-28 14:40:06 +02:00
HeaderComponent,
2020-01-20 15:12:51 +01:00
SearchTypeaheadComponent,
SuggestionComponent,
2019-08-28 14:40:06 +02:00
CustomModalComponent,
2019-08-28 14:40:06 +02:00
WelcomeModalComponent,
InstanceConfigWarningModalComponent
2016-09-06 22:40:57 +02:00
],
2016-11-20 17:18:15 +01:00
imports: [
2016-09-06 22:40:57 +02:00
BrowserModule,
2016-09-09 22:23:41 +02:00
2016-11-20 17:18:15 +01:00
CoreModule,
SharedModule,
CoreModule,
LoginModule,
2018-01-30 13:27:07 +01:00
ResetPasswordModule,
2018-07-19 16:17:54 +02:00
SearchModule,
2016-11-20 17:18:15 +01:00
SharedModule,
2017-03-12 18:40:05 +01:00
VideosModule,
MetaModule.forRoot({
provide: MetaLoader,
2020-05-11 13:39:06 +02:00
useFactory: (serverService: ServerService) => {
return new MetaStaticLoader({
pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
pageTitleSeparator: ' - ',
get applicationName () { return serverService.getTmpConfig().instance.name },
defaults: {
get title () { return serverService.getTmpConfig().instance.name },
get description () { return serverService.getTmpConfig().instance.shortDescription }
}
})
},
2018-03-22 14:13:30 +01:00
deps: [ ServerService ]
2018-05-31 11:35:01 +02:00
}),
2018-05-31 14:43:48 +02:00
AppRoutingModule // Put it after all the module because it has the 404 route
2016-09-06 22:40:57 +02:00
],
2020-02-07 15:51:19 +01:00
2018-05-31 18:12:15 +02:00
providers: [
{
provide: APP_BASE_HREF,
useValue: '/'
},
2018-05-31 18:12:15 +02:00
{
provide: TRANSLATIONS,
useFactory: (locale: string) => {
2020-04-03 14:55:16 +02:00
// Default locale, nothing to translate
2018-06-06 17:37:13 +02:00
const completeLocale = getCompleteLocale(locale)
if (isDefaultLocale(completeLocale)) return ''
2018-05-31 18:12:15 +02:00
2018-06-06 17:37:13 +02:00
const fileLocale = buildFileLocale(locale)
2020-04-03 14:55:16 +02:00
return require(`raw-loader!../locale/angular.${fileLocale}.xlf`).default
2018-05-31 18:12:15 +02:00
},
deps: [ LOCALE_ID ]
},
{ provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
]
2016-09-06 22:40:57 +02:00
})
2017-12-11 17:36:46 +01:00
export class AppModule {}