]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/main.ts
Add missing translations
[github/Chocobozzz/PeerTube.git] / client / src / main.ts
1 import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
2 import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
3
4 import { AppModule } from './app/app.module'
5 import { environment } from './environments/environment'
6
7 import { hmrBootstrap } from './hmr'
8
9 let providers = []
10 if (environment.production) {
11 enableProdMode()
12 }
13
14 if (environment.production === false && window.location.search === '?lang=fr') {
15 const translations = require(`raw-loader!./locale/target/messages_fr.xml`)
16
17 providers = [
18 { provide: TRANSLATIONS, useValue: translations },
19 { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
20 ]
21 }
22
23 const bootstrap = () => platformBrowserDynamic()
24 .bootstrapModule(AppModule, { providers })
25 .then(bootstrapModule => {
26 // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed
27 // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?
28 // if ('serviceWorker' in navigator && environment.production) {
29 // navigator.serviceWorker.register('/ngsw-worker.js')
30 // .catch(err => console.error('Cannot register service worker.', err))
31 // }
32
33 if (navigator.serviceWorker) {
34 navigator.serviceWorker.getRegistrations()
35 .then(registrations => {
36 for (const registration of registrations) {
37 registration.unregister()
38 }
39 })
40 }
41
42 return bootstrapModule
43 })
44 .catch(err => {
45 console.error(err)
46 return null
47 })
48
49 if (environment.hmr) {
50 if (module[ 'hot' ]) {
51 hmrBootstrap(module, bootstrap)
52 } else {
53 console.error('HMR is not enabled for webpack-dev-server!')
54 console.log('Are you using the --hmr flag for ng serve?')
55 }
56 } else {
57 bootstrap()
58 }