diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-31 18:12:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-05 08:43:01 +0200 |
commit | 989e526abf0c0dd7958deb630df009608561bb67 (patch) | |
tree | 5d948bf953a7006b1d6b8c34fb03da1df612a50f /client/src/app/app.module.ts | |
parent | 1dd59831f80ff4d49f3b60c8c3b2aabfb1512eeb (diff) | |
download | PeerTube-989e526abf0c0dd7958deb630df009608561bb67.tar.gz PeerTube-989e526abf0c0dd7958deb630df009608561bb67.tar.zst PeerTube-989e526abf0c0dd7958deb630df009608561bb67.zip |
Prepare i18n files
Diffstat (limited to 'client/src/app/app.module.ts')
-rw-r--r-- | client/src/app/app.module.ts | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index cf533629f..44552021f 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' |
2 | import { BrowserModule } from '@angular/platform-browser' | 2 | import { BrowserModule } from '@angular/platform-browser' |
3 | import { AboutModule } from '@app/about' | 3 | import { AboutModule } from '@app/about' |
4 | import { ServerService } from '@app/core' | 4 | import { ServerService } from '@app/core' |
@@ -16,6 +16,7 @@ import { MenuComponent } from './menu' | |||
16 | import { SharedModule } from './shared' | 16 | import { SharedModule } from './shared' |
17 | import { SignupModule } from './signup' | 17 | import { SignupModule } from './signup' |
18 | import { VideosModule } from './videos' | 18 | import { VideosModule } from './videos' |
19 | import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n' | ||
19 | 20 | ||
20 | export function metaFactory (serverService: ServerService): MetaLoader { | 21 | export function metaFactory (serverService: ServerService): MetaLoader { |
21 | return new MetaStaticLoader({ | 22 | return new MetaStaticLoader({ |
@@ -61,6 +62,21 @@ export function metaFactory (serverService: ServerService): MetaLoader { | |||
61 | 62 | ||
62 | AppRoutingModule // Put it after all the module because it has the 404 route | 63 | AppRoutingModule // Put it after all the module because it has the 404 route |
63 | ], | 64 | ], |
64 | providers: [ ] | 65 | providers: [ |
66 | { | ||
67 | provide: TRANSLATIONS, | ||
68 | useFactory: (locale) => { | ||
69 | const fileLocale = buildFileLocale(locale) | ||
70 | |||
71 | // Default locale, nothing to translate | ||
72 | const defaultFileLocale = buildFileLocale(getDefaultLocale()) | ||
73 | if (fileLocale === defaultFileLocale) return '' | ||
74 | |||
75 | return require(`raw-loader!../locale/target/messages_${fileLocale}.xml`) | ||
76 | }, | ||
77 | deps: [ LOCALE_ID ] | ||
78 | }, | ||
79 | { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' } | ||
80 | ] | ||
65 | }) | 81 | }) |
66 | export class AppModule {} | 82 | export class AppModule {} |