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 @@ + diff --git a/src/Ombi/package-lock.json b/src/Ombi/package-lock.json index 7bc72d976..8a45785c3 100644 --- a/src/Ombi/package-lock.json +++ b/src/Ombi/package-lock.json @@ -107,6 +107,16 @@ "resolved": "https://registry.npmjs.org/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-1.0.0-beta.5.tgz", "integrity": "sha1-2iuQZrNwGihMrFoWFop33vlHtKs=" }, + "@ngx-translate/core": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@ngx-translate/core/-/core-8.0.0.tgz", + "integrity": "sha1-dR/WtRLYDzp0jS3o38lt/vopr+A=" + }, + "@ngx-translate/http-loader": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@ngx-translate/http-loader/-/http-loader-2.0.0.tgz", + "integrity": "sha1-nBbQfNBwxnraJwoulAKB64JrP0M=" + }, "@types/chai": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.0.4.tgz", diff --git a/src/Ombi/package.json b/src/Ombi/package.json index 250056f69..473e82e2f 100644 --- a/src/Ombi/package.json +++ b/src/Ombi/package.json @@ -22,6 +22,8 @@ "@angular/platform-server": "^4.4.6", "@angular/router": "^4.4.6", "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5", + "@ngx-translate/core": "^8.0.0", + "@ngx-translate/http-loader": "^2.0.0", "@types/core-js": "^0.9.43", "@types/extract-text-webpack-plugin": "^3.0.0", "@types/intro.js": "^2.4.3", diff --git a/src/Ombi/webpack.config.vendor.ts b/src/Ombi/webpack.config.vendor.ts index 8737367c1..4732207c6 100644 --- a/src/Ombi/webpack.config.vendor.ts +++ b/src/Ombi/webpack.config.vendor.ts @@ -64,6 +64,8 @@ module.exports = (env: any) => { "ngx-clipboard", "angular2-jwt", "ng2-cookies", + "@ngx-translate/core", + "@ngx-translate/http-loader", ], }, output: { diff --git a/src/Ombi/wwwroot/translations/de.json b/src/Ombi/wwwroot/translations/de.json new file mode 100644 index 000000000..c9d036ae5 --- /dev/null +++ b/src/Ombi/wwwroot/translations/de.json @@ -0,0 +1,7 @@ +{ + "Login": { + "SignInButton": "Eintragen", + "UsernamePlaceholder":"Useraname", + "PasswordPlaceholder":"Password", + } +} \ No newline at end of file diff --git a/src/Ombi/wwwroot/translations/en.json b/src/Ombi/wwwroot/translations/en.json new file mode 100644 index 000000000..d789af942 --- /dev/null +++ b/src/Ombi/wwwroot/translations/en.json @@ -0,0 +1,9 @@ +{ + "Login": { + "SignInButton": "Sign in", + "UsernamePlaceholder":"Username", + "PasswordPlaceholder":"Password", + "RememberMe":"Remember Me", + "ForgottenPassword":"Forgot your password?" + } +} \ No newline at end of file