diff options
author | Chocobozzz <me@florianbigard.com> | 2020-02-07 15:51:19 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-02-10 16:39:28 +0100 |
commit | 361dcebc75dea74947b6c3aafd9d7d720c054b01 (patch) | |
tree | 5edf2a0d871097ba7da2b974b8ccdef9c6b73261 /client/src/main.ts | |
parent | f77eb73b5e02bed9e223dafc1c203ceb7c05b6e5 (diff) | |
download | PeerTube-361dcebc75dea74947b6c3aafd9d7d720c054b01.tar.gz PeerTube-361dcebc75dea74947b6c3aafd9d7d720c054b01.tar.zst PeerTube-361dcebc75dea74947b6c3aafd9d7d720c054b01.zip |
Support i18n build
Diffstat (limited to 'client/src/main.ts')
-rw-r--r-- | client/src/main.ts | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/client/src/main.ts b/client/src/main.ts index 2b65072ad..3fb9b346e 100644 --- a/client/src/main.ts +++ b/client/src/main.ts | |||
@@ -1,31 +1,17 @@ | |||
1 | import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' | 1 | import { enableProdMode } from '@angular/core' |
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' | 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' |
3 | 3 | ||
4 | import { AppModule } from './app/app.module' | 4 | import { AppModule } from './app/app.module' |
5 | import { environment } from './environments/environment' | 5 | import { environment } from './environments/environment' |
6 | 6 | ||
7 | import { hmrBootstrap } from './hmr' | 7 | import { hmrBootstrap } from './hmr' |
8 | import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' | ||
9 | import { buildFileLocale } from '../../shared' | ||
10 | 8 | ||
11 | let providers: any[] = [] | ||
12 | if (environment.production) { | 9 | if (environment.production) { |
13 | enableProdMode() | 10 | enableProdMode() |
14 | } | 11 | } |
15 | 12 | ||
16 | // Template translation, should be in the bootstrap step | ||
17 | if (isOnDevLocale()) { | ||
18 | const locale = buildFileLocale(getDevLocale()) | ||
19 | const translations = require(`raw-loader!./locale/angular.${locale}.xlf`) | ||
20 | |||
21 | providers = [ | ||
22 | { provide: TRANSLATIONS, useValue: translations }, | ||
23 | { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' } | ||
24 | ] | ||
25 | } | ||
26 | |||
27 | const bootstrap = () => platformBrowserDynamic() | 13 | const bootstrap = () => platformBrowserDynamic() |
28 | .bootstrapModule(AppModule, { providers }) | 14 | .bootstrapModule(AppModule) |
29 | .then(bootstrapModule => { | 15 | .then(bootstrapModule => { |
30 | // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed | 16 | // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed |
31 | // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed? | 17 | // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed? |
@@ -36,11 +22,11 @@ const bootstrap = () => platformBrowserDynamic() | |||
36 | 22 | ||
37 | if (navigator.serviceWorker && typeof navigator.serviceWorker.getRegistrations === 'function') { | 23 | if (navigator.serviceWorker && typeof navigator.serviceWorker.getRegistrations === 'function') { |
38 | navigator.serviceWorker.getRegistrations() | 24 | navigator.serviceWorker.getRegistrations() |
39 | .then(registrations => { | 25 | .then(registrations => { |
40 | for (const registration of registrations) { | 26 | for (const registration of registrations) { |
41 | registration.unregister() | 27 | registration.unregister() |
42 | } | 28 | } |
43 | }) | 29 | }) |
44 | } | 30 | } |
45 | 31 | ||
46 | return bootstrapModule | 32 | return bootstrapModule |