diff --git a/src/Ombi/ClientApp/app/app.component.ts b/src/Ombi/ClientApp/app/app.component.ts index 2e67aeb40..471fcc760 100644 --- a/src/Ombi/ClientApp/app/app.component.ts +++ b/src/Ombi/ClientApp/app/app.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from "@angular/core"; import { NavigationStart, Router } from "@angular/router"; +import { TranslateService } from "@ngx-translate/core"; import { AuthService } from "./auth/auth.service"; import { ILocalUser } from "./auth/IUserLogin"; import { NotificationService } from "./services"; @@ -23,7 +24,16 @@ export class AppComponent implements OnInit { public authService: AuthService, private readonly router: Router, private readonly settingsService: SettingsService, - private readonly jobService: JobService) { } + private readonly jobService: JobService, + private readonly translate: TranslateService) { + this.translate.addLangs(["en", "de"]); + // this language will be used as a fallback when a translation isn't found in the current language + this.translate.setDefaultLang("en"); + + // See if we can match the supported langs with the current browser lang + const browserLang: string = translate.getBrowserLang(); + this.translate.use(browserLang.match(/en|fr/) ? browserLang : "en"); + } public ngOnInit() { this.user = this.authService.claims(); diff --git a/src/Ombi/ClientApp/app/app.module.ts b/src/Ombi/ClientApp/app/app.module.ts index 4739bcc69..616fdf75c 100644 --- a/src/Ombi/ClientApp/app/app.module.ts +++ b/src/Ombi/ClientApp/app/app.module.ts @@ -1,3 +1,4 @@ +import { HttpClient, HttpClientModule} from "@angular/common/http"; import { NgModule } from "@angular/core"; import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { HttpModule } from "@angular/http"; @@ -9,6 +10,8 @@ import { RouterModule, Routes } from "@angular/router"; // Third Party //import { DragulaModule, DragulaService } from 'ng2-dragula/ng2-dragula'; import { NgbModule } from "@ng-bootstrap/ng-bootstrap"; +import { TranslateLoader, TranslateModule } from "@ngx-translate/core"; +import { TranslateHttpLoader } from "@ngx-translate/http-loader"; import { GrowlModule } from "primeng/components/growl/growl"; import { ButtonModule, CaptchaModule,ConfirmationService, ConfirmDialogModule, DataTableModule,DialogModule, SharedModule, TooltipModule } from "primeng/primeng"; @@ -39,7 +42,6 @@ import { SearchModule } from "./search/search.module"; import { SettingsModule } from "./settings/settings.module"; import { UserManagementModule } from "./usermanagement/usermanagement.module"; import { WizardModule } from "./wizard/wizard.module"; -//import { PipeModule } from './pipes/pipe.module'; const routes: Routes = [ { path: "*", component: PageNotFoundComponent }, @@ -53,10 +55,16 @@ const routes: Routes = [ { path: "landingpage", component: LandingPageComponent }, ]; +// AoT requires an exported function for factories +export function HttpLoaderFactory(http: HttpClient) { + return new TranslateHttpLoader(http, "/translations/", ".json"); +} + @NgModule({ imports: [ RouterModule.forRoot(routes), BrowserModule, + HttpClientModule, BrowserAnimationsModule, HttpModule, GrowlModule, @@ -71,7 +79,6 @@ const routes: Routes = [ DialogModule, MatButtonModule, NgbModule.forRoot(), - //DragulaModule, MatCardModule, MatInputModule, MatTabsModule, @@ -80,7 +87,14 @@ const routes: Routes = [ RequestsModule, CaptchaModule, TooltipModule, - ConfirmDialogModule, + ConfirmDialogModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient], + }, + }), ], declarations: [ AppComponent, @@ -100,8 +114,7 @@ const routes: Routes = [ StatusService, LandingPageService, ConfirmationService, -ImageService, - //DragulaService + ImageService, ], bootstrap: [AppComponent], }) diff --git a/src/Ombi/ClientApp/app/login/login.component.html b/src/Ombi/ClientApp/app/login/login.component.html index ec3fff4df..c07d83e0e 100644 --- a/src/Ombi/ClientApp/app/login/login.component.html +++ b/src/Ombi/ClientApp/app/login/login.component.html @@ -15,20 +15,20 @@ include the remember me checkbox
- Forgot your password? + diff --git a/src/Ombi/Ombi.csproj b/src/Ombi/Ombi.csproj index 24c77d20b..cb668baef 100644 --- a/src/Ombi/Ombi.csproj +++ b/src/Ombi/Ombi.csproj @@ -88,6 +88,7 @@