mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 01:32:55 -07:00
Localize dates
This commit is contained in:
parent
05b7ce6c7e
commit
fa1e711a25
7 changed files with 58 additions and 8 deletions
|
@ -66,6 +66,39 @@ import { TranslateHttpLoader } from "@ngx-translate/http-loader";
|
||||||
import { UnauthorizedInterceptor } from "./auth/unauthorized.interceptor";
|
import { UnauthorizedInterceptor } from "./auth/unauthorized.interceptor";
|
||||||
import { environment } from "../environments/environment";
|
import { environment } from "../environments/environment";
|
||||||
|
|
||||||
|
import { registerLocaleData } from '@angular/common';
|
||||||
|
// TODO: lazy load locales, probably somewhere in app.component
|
||||||
|
import localeDa from '@angular/common/locales/da';
|
||||||
|
import localeDe from '@angular/common/locales/de';
|
||||||
|
import localeEs from '@angular/common/locales/es';
|
||||||
|
import localeFr from '@angular/common/locales/fr';
|
||||||
|
import localeIt from '@angular/common/locales/it';
|
||||||
|
import localeHu from '@angular/common/locales/hu';
|
||||||
|
import localeNl from '@angular/common/locales/nl';
|
||||||
|
// import localeNo from '@angular/common/locales/no';
|
||||||
|
import localePl from '@angular/common/locales/pl';
|
||||||
|
import localePt from '@angular/common/locales/pt';
|
||||||
|
import localeSk from '@angular/common/locales/sk';
|
||||||
|
import localeSv from '@angular/common/locales/sv';
|
||||||
|
import localeBg from '@angular/common/locales/bg';
|
||||||
|
import localeRu from '@angular/common/locales/ru';
|
||||||
|
|
||||||
|
|
||||||
|
registerLocaleData(localeDa);
|
||||||
|
registerLocaleData(localeDe);
|
||||||
|
registerLocaleData(localeEs);
|
||||||
|
registerLocaleData(localeFr);
|
||||||
|
registerLocaleData(localeIt);
|
||||||
|
registerLocaleData(localeHu);
|
||||||
|
registerLocaleData(localeNl);
|
||||||
|
// registerLocaleData(localeNo);
|
||||||
|
registerLocaleData(localePl);
|
||||||
|
registerLocaleData(localePt);
|
||||||
|
registerLocaleData(localeSk);
|
||||||
|
registerLocaleData(localeSv);
|
||||||
|
registerLocaleData(localeBg);
|
||||||
|
registerLocaleData(localeRu);
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: "*", component: PageNotFoundComponent },
|
{ path: "*", component: PageNotFoundComponent },
|
||||||
{ path: "", redirectTo: "/discover", pathMatch: "full" },
|
{ path: "", redirectTo: "/discover", pathMatch: "full" },
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<mat-card class="issue-card" *ngIf="!deleted">
|
<mat-card class="issue-card" *ngIf="!deleted">
|
||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<mat-card-title>{{issue.subject}}</mat-card-title>
|
<mat-card-title>{{issue.subject}}</mat-card-title>
|
||||||
<mat-card-subtitle>{{issue.userReported?.userName}} on {{issue.createdDate | date:short}}</mat-card-subtitle>
|
<mat-card-subtitle>{{issue.userReported?.userName}} on {{issue.createdDate | localizedDate:short}}</mat-card-subtitle>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
<div *ngIf="request">
|
<div *ngIf="request">
|
||||||
<span class="label">{{'MediaDetails.RequestDate' | translate }}</span>
|
<span class="label">{{'MediaDetails.RequestDate' | translate }}</span>
|
||||||
{{request.requestedDate | date}}
|
{{request.requestedDate | localizedDate}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="request && request.denied">
|
<div *ngIf="request && request.denied">
|
||||||
|
@ -78,11 +78,11 @@
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<span class="label">{{'MediaDetails.TheatricalRelease' | translate }}</span>
|
<span class="label">{{'MediaDetails.TheatricalRelease' | translate }}</span>
|
||||||
{{movie.releaseDate | date: 'mediumDate'}}
|
{{movie.releaseDate | localizedDate: 'mediumDate'}}
|
||||||
|
|
||||||
<div *ngIf="movie.digitalReleaseDate">
|
<div *ngIf="movie.digitalReleaseDate">
|
||||||
<span class="label">{{'MediaDetails.DigitalRelease' | translate }}</span>
|
<span class="label">{{'MediaDetails.DigitalRelease' | translate }}</span>
|
||||||
{{movie.digitalReleaseDate | date: 'mediumDate'}}
|
{{movie.digitalReleaseDate | localizedDate: 'mediumDate'}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="movie.voteCount">
|
<div *ngIf="movie.voteCount">
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<span id="status">{{ getTVStatusLabel()}}</span>
|
<span id="status">{{ getTVStatusLabel()}}</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="label">{{'MediaDetails.FirstAired' | translate }}</span>
|
<span class="label">{{'MediaDetails.FirstAired' | translate }}</span>
|
||||||
{{tv.firstAired | date: 'mediumDate'}}
|
{{tv.firstAired | localizedDate: 'mediumDate'}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="seasonCount">
|
<div *ngIf="seasonCount">
|
||||||
|
|
16
src/Ombi/ClientApp/src/app/pipes/LocalizedDate.ts
Normal file
16
src/Ombi/ClientApp/src/app/pipes/LocalizedDate.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { DatePipe } from '@angular/common';
|
||||||
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'localizedDate',
|
||||||
|
pure: false
|
||||||
|
})
|
||||||
|
export class LocalizedDatePipe implements PipeTransform {
|
||||||
|
constructor(private translateService: TranslateService) {}
|
||||||
|
|
||||||
|
transform(value: any, pattern: string = 'mediumDate'): any {
|
||||||
|
const datePipe: DatePipe = new DatePipe(this.translateService.currentLang);
|
||||||
|
return datePipe.transform(value, pattern);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import { ModuleWithProviders, NgModule } from "@angular/core";
|
import { ModuleWithProviders, NgModule } from "@angular/core";
|
||||||
import { HumanizePipe } from "./HumanizePipe";
|
import { HumanizePipe } from "./HumanizePipe";
|
||||||
|
import { LocalizedDatePipe } from "./LocalizedDate";
|
||||||
import { ThousandShortPipe } from "./ThousandShortPipe";
|
import { ThousandShortPipe } from "./ThousandShortPipe";
|
||||||
import { SafePipe } from "./SafePipe";
|
import { SafePipe } from "./SafePipe";
|
||||||
import { QualityPipe } from "./QualityPipe";
|
import { QualityPipe } from "./QualityPipe";
|
||||||
|
@ -7,8 +8,8 @@ import { UserLocalePipe } from "./UserLocalePipe";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [],
|
imports: [],
|
||||||
declarations: [HumanizePipe, ThousandShortPipe, SafePipe, QualityPipe, UserLocalePipe],
|
declarations: [HumanizePipe, ThousandShortPipe, SafePipe, QualityPipe, UserLocalePipe, LocalizedDatePipe ],
|
||||||
exports: [HumanizePipe, ThousandShortPipe, SafePipe, QualityPipe, UserLocalePipe],
|
exports: [HumanizePipe, ThousandShortPipe, SafePipe, QualityPipe, UserLocalePipe, LocalizedDatePipe ],
|
||||||
})
|
})
|
||||||
export class PipeModule {
|
export class PipeModule {
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<small>Updated at {{data.updateDate | date}}</small>
|
<small>Updated at {{data.updateDate | localizedDate}}</small>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue