]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/app.module.ts
Prepare i18n files
[github/Chocobozzz/PeerTube.git] / client / src / app / app.module.ts
index 77d68a4ec1ad5a236b16d684a2b2f56b00aade64..44552021f3aedcbb351f35c52d4c00b239c14552 100644 (file)
@@ -1,12 +1,11 @@
-import { NgModule } from '@angular/core'
+import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
 import { BrowserModule } from '@angular/platform-browser'
 import { AboutModule } from '@app/about'
 import { ServerService } from '@app/core'
 import { ResetPasswordModule } from '@app/reset-password'
 
 import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
-
-import { AccountModule } from './account'
+import { ClipboardModule } from 'ngx-clipboard'
 
 import { AppRoutingModule } from './app-routing.module'
 import { AppComponent } from './app.component'
@@ -17,6 +16,7 @@ import { MenuComponent } from './menu'
 import { SharedModule } from './shared'
 import { SignupModule } from './signup'
 import { VideosModule } from './videos'
+import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n'
 
 export function metaFactory (serverService: ServerService): MetaLoader {
   return new MetaStaticLoader({
@@ -40,13 +40,12 @@ export function metaFactory (serverService: ServerService): MetaLoader {
   ],
   imports: [
     BrowserModule,
+    // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
+    ClipboardModule,
 
     CoreModule,
     SharedModule,
 
-    AppRoutingModule,
-
-    AccountModule,
     CoreModule,
     LoginModule,
     ResetPasswordModule,
@@ -59,8 +58,25 @@ export function metaFactory (serverService: ServerService): MetaLoader {
       provide: MetaLoader,
       useFactory: (metaFactory),
       deps: [ ServerService ]
-    })
+    }),
+
+    AppRoutingModule // Put it after all the module because it has the 404 route
   ],
-  providers: [ ]
+  providers: [
+    {
+      provide: TRANSLATIONS,
+      useFactory: (locale) => {
+        const fileLocale = buildFileLocale(locale)
+
+        // Default locale, nothing to translate
+        const defaultFileLocale = buildFileLocale(getDefaultLocale())
+        if (fileLocale === defaultFileLocale) return ''
+
+        return require(`raw-loader!../locale/target/messages_${fileLocale}.xml`)
+      },
+      deps: [ LOCALE_ID ]
+    },
+    { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
+  ]
 })
 export class AppModule {}