]>
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' |
e78980eb | 8 | import 'focus-visible' |
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, | |
23bcf666 | 49 | |
693b1aba C |
50 | CoreModule, |
51 | SharedModule, | |
52 | ||
693b1aba C |
53 | CoreModule, |
54 | LoginModule, | |
ecb4e35f | 55 | ResetPasswordModule, |
a184c71b | 56 | SignupModule, |
57c36b27 | 57 | SearchModule, |
693b1aba | 58 | SharedModule, |
55b33946 C |
59 | VideosModule, |
60 | ||
61 | MetaModule.forRoot({ | |
62 | provide: MetaLoader, | |
63ac2857 C |
63 | useFactory: (metaFactory), |
64 | deps: [ ServerService ] | |
a51bad1a C |
65 | }), |
66 | ||
a9614776 | 67 | AppRoutingModule // Put it after all the module because it has the 404 route |
ab32b0fc | 68 | ], |
989e526a C |
69 | providers: [ |
70 | { | |
71 | provide: TRANSLATIONS, | |
244b4ae3 | 72 | useFactory: (locale: string) => { |
74b7c6d4 C |
73 | // On dev mode, test localization |
74 | if (isOnDevLocale()) { | |
c0ffdd09 | 75 | locale = buildFileLocale(getDevLocale()) |
74b7c6d4 | 76 | return require(`raw-loader!../locale/target/angular_${locale}.xml`) |
e309822b C |
77 | } |
78 | ||
989e526a | 79 | // Default locale, nothing to translate |
74b7c6d4 C |
80 | const completeLocale = getCompleteLocale(locale) |
81 | if (isDefaultLocale(completeLocale)) return '' | |
989e526a | 82 | |
74b7c6d4 | 83 | const fileLocale = buildFileLocale(locale) |
f07d6385 | 84 | return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`) |
989e526a C |
85 | }, |
86 | deps: [ LOCALE_ID ] | |
87 | }, | |
88 | { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' } | |
89 | ] | |
ab32b0fc | 90 | }) |
63c4db6d | 91 | export class AppModule {} |