]>
Commit | Line | Data |
---|---|---|
989e526a | 1 | import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' |
df98563e | 2 | import { BrowserModule } from '@angular/platform-browser' |
63ac2857 | 3 | import { ServerService } from '@app/core' |
ecb4e35f | 4 | import { ResetPasswordModule } from '@app/reset-password' |
ab32b0fc | 5 | |
ecb4e35f | 6 | import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' |
230de99e | 7 | import { ClipboardModule } from 'ngx-clipboard' |
ee1fc23a | 8 | import { HotkeyModule, IHotkeyOptions } from 'angular2-hotkeys' |
ecb4e35f | 9 | |
df98563e C |
10 | import { AppRoutingModule } from './app-routing.module' |
11 | import { AppComponent } from './app.component' | |
df98563e | 12 | import { CoreModule } from './core' |
ecb4e35f | 13 | import { HeaderComponent } from './header' |
df98563e | 14 | import { LoginModule } from './login' |
ecb4e35f | 15 | import { MenuComponent } from './menu' |
df98563e | 16 | import { SharedModule } from './shared' |
ecb4e35f | 17 | import { SignupModule } from './signup' |
df98563e | 18 | import { VideosModule } from './videos' |
b7f1747d | 19 | import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '../../../shared/models/i18n' |
74b7c6d4 | 20 | import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' |
8afc19a6 | 21 | import { LanguageChooserComponent } from '@app/menu/language-chooser.component' |
57c36b27 | 22 | import { SearchModule } from '@app/search' |
693b1aba | 23 | |
63ac2857 | 24 | export function metaFactory (serverService: ServerService): MetaLoader { |
758b996d C |
25 | return new MetaStaticLoader({ |
26 | pageTitlePositioning: PageTitlePositioning.PrependPageTitle, | |
27 | pageTitleSeparator: ' - ', | |
63ac2857 | 28 | get applicationName () { return serverService.getConfig().instance.name }, |
758b996d | 29 | defaults: { |
63ac2857 C |
30 | get title () { return serverService.getConfig().instance.name }, |
31 | get description () { return serverService.getConfig().instance.shortDescription } | |
758b996d | 32 | } |
df98563e | 33 | }) |
758b996d | 34 | } |
b58c69a1 | 35 | |
ab32b0fc C |
36 | @NgModule({ |
37 | bootstrap: [ AppComponent ], | |
38 | declarations: [ | |
b33f657c C |
39 | AppComponent, |
40 | ||
41 | MenuComponent, | |
8afc19a6 | 42 | LanguageChooserComponent, |
f3aaa9a9 | 43 | HeaderComponent |
ab32b0fc | 44 | ], |
693b1aba | 45 | imports: [ |
ab32b0fc | 46 | BrowserModule, |
230de99e C |
47 | // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133 |
48 | ClipboardModule, | |
ee1fc23a RK |
49 | HotkeyModule.forRoot({ |
50 | cheatSheetCloseEsc: true | |
51 | } as IHotkeyOptions), | |
23bcf666 | 52 | |
693b1aba C |
53 | CoreModule, |
54 | SharedModule, | |
55 | ||
693b1aba C |
56 | CoreModule, |
57 | LoginModule, | |
ecb4e35f | 58 | ResetPasswordModule, |
a184c71b | 59 | SignupModule, |
57c36b27 | 60 | SearchModule, |
693b1aba | 61 | SharedModule, |
55b33946 C |
62 | VideosModule, |
63 | ||
64 | MetaModule.forRoot({ | |
65 | provide: MetaLoader, | |
63ac2857 C |
66 | useFactory: (metaFactory), |
67 | deps: [ ServerService ] | |
a51bad1a C |
68 | }), |
69 | ||
a9614776 | 70 | AppRoutingModule // Put it after all the module because it has the 404 route |
ab32b0fc | 71 | ], |
989e526a C |
72 | providers: [ |
73 | { | |
74 | provide: TRANSLATIONS, | |
75 | useFactory: (locale) => { | |
74b7c6d4 C |
76 | // On dev mode, test localization |
77 | if (isOnDevLocale()) { | |
c0ffdd09 | 78 | locale = buildFileLocale(getDevLocale()) |
74b7c6d4 | 79 | return require(`raw-loader!../locale/target/angular_${locale}.xml`) |
e309822b C |
80 | } |
81 | ||
989e526a | 82 | // Default locale, nothing to translate |
74b7c6d4 C |
83 | const completeLocale = getCompleteLocale(locale) |
84 | if (isDefaultLocale(completeLocale)) return '' | |
989e526a | 85 | |
74b7c6d4 | 86 | const fileLocale = buildFileLocale(locale) |
f07d6385 | 87 | return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`) |
989e526a C |
88 | }, |
89 | deps: [ LOCALE_ID ] | |
90 | }, | |
91 | { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' } | |
92 | ] | |
ab32b0fc | 93 | }) |
63c4db6d | 94 | export class AppModule {} |