1
0
Fork 0
peertube/client/src/app/app.module.ts

89 lines
2.7 KiB
TypeScript
Raw Normal View History

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