]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/main.ts
Add missing translations
[github/Chocobozzz/PeerTube.git] / client / src / main.ts
CommitLineData
e309822b 1import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
b6827820 2import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
63c4db6d 3
b6827820
C
4import { AppModule } from './app/app.module'
5import { environment } from './environments/environment'
63c4db6d 6
77d07d69
C
7import { hmrBootstrap } from './hmr'
8
e309822b 9let providers = []
63c4db6d 10if (environment.production) {
b6827820 11 enableProdMode()
63c4db6d
C
12}
13
e309822b
C
14if (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
77d07d69 23const bootstrap = () => platformBrowserDynamic()
e309822b 24 .bootstrapModule(AppModule, { providers })
78967fca 25 .then(bootstrapModule => {
fed95155 26 // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed
78967fca 27 // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?
fed95155
C
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
73e09f27
C
33 if (navigator.serviceWorker) {
34 navigator.serviceWorker.getRegistrations()
35 .then(registrations => {
36 for (const registration of registrations) {
37 registration.unregister()
38 }
39 })
40 }
78967fca
C
41
42 return bootstrapModule
43 })
44 .catch(err => {
45 console.error(err)
46 return null
47 })
77d07d69
C
48
49if (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}