aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.module.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-31 18:12:15 +0200
committerChocobozzz <me@florianbigard.com>2018-06-05 08:43:01 +0200
commit989e526abf0c0dd7958deb630df009608561bb67 (patch)
tree5d948bf953a7006b1d6b8c34fb03da1df612a50f /client/src/app/app.module.ts
parent1dd59831f80ff4d49f3b60c8c3b2aabfb1512eeb (diff)
downloadPeerTube-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.ts20
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 @@
1import { NgModule } from '@angular/core' 1import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
2import { BrowserModule } from '@angular/platform-browser' 2import { BrowserModule } from '@angular/platform-browser'
3import { AboutModule } from '@app/about' 3import { AboutModule } from '@app/about'
4import { ServerService } from '@app/core' 4import { ServerService } from '@app/core'
@@ -16,6 +16,7 @@ import { MenuComponent } from './menu'
16import { SharedModule } from './shared' 16import { SharedModule } from './shared'
17import { SignupModule } from './signup' 17import { SignupModule } from './signup'
18import { VideosModule } from './videos' 18import { VideosModule } from './videos'
19import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n'
19 20
20export function metaFactory (serverService: ServerService): MetaLoader { 21export 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})
66export class AppModule {} 82export class AppModule {}