mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Fix: include number placeholder in relative date strings
This commit is contained in:
parent
584f1361ad
commit
342e6d4679
@ -7388,95 +7388,95 @@
|
||||
<context context-type="linenumber">36</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="4272436583644511364" datatype="html">
|
||||
<source>Just now</source>
|
||||
<trans-unit id="7811681478769461161" datatype="html">
|
||||
<source>%s year ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">14</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="3393387677918927062" datatype="html">
|
||||
<source>%s years ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">15</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="3053246523831285824" datatype="html">
|
||||
<source>%s month ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">19</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="1158628882375251480" datatype="html">
|
||||
<source>%s months ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">20</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="7039133412826927309" datatype="html">
|
||||
<source>%s week ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">24</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="2896962543647781653" datatype="html">
|
||||
<source>%s weeks ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">25</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="91416192007234700" datatype="html">
|
||||
<source>%s day ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">29</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="5601594741748068208" datatype="html">
|
||||
<source>%s days ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">30</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="8387405724402999437" datatype="html">
|
||||
<source>%s hour ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">34</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="2008395012733474465" datatype="html">
|
||||
<source>%s hours ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">35</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="5782387980670840884" datatype="html">
|
||||
<source>%s minute ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">39</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="8456127468852940807" datatype="html">
|
||||
<source>year ago</source>
|
||||
<trans-unit id="7573942914011074807" datatype="html">
|
||||
<source>%s minutes ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">42</context>
|
||||
<context context-type="linenumber">40</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="963494111451627204" datatype="html">
|
||||
<source>years ago</source>
|
||||
<trans-unit id="4272436583644511364" datatype="html">
|
||||
<source>Just now</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">43</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="1919405338795657780" datatype="html">
|
||||
<source>month ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">47</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="6041340836190906216" datatype="html">
|
||||
<source>months ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">48</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="4072659649620334828" datatype="html">
|
||||
<source>week ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">52</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="2871318661796659216" datatype="html">
|
||||
<source>weeks ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">53</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="1328378419272652134" datatype="html">
|
||||
<source>day ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">57</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="5620397708418210833" datatype="html">
|
||||
<source>days ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">58</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="4259498317457105735" datatype="html">
|
||||
<source>hour ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">62</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="7576594819545407052" datatype="html">
|
||||
<source>hours ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">63</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="4063456036422970205" datatype="html">
|
||||
<source>minute ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">67</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="6906829094715901970" datatype="html">
|
||||
<source>minutes ago</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/pipes/custom-date.pipe.ts</context>
|
||||
<context context-type="linenumber">68</context>
|
||||
<context context-type="linenumber">72</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="7536524521722799066" datatype="html">
|
||||
|
@ -1,10 +1,7 @@
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { CustomDatePipe } from './custom-date.pipe'
|
||||
import { SettingsService } from '../services/settings.service'
|
||||
import {
|
||||
HttpClientTestingModule,
|
||||
HttpTestingController,
|
||||
} from '@angular/common/http/testing'
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing'
|
||||
import { DatePipe } from '@angular/common'
|
||||
|
||||
describe('CustomDatePipe', () => {
|
||||
|
@ -9,6 +9,39 @@ const FORMAT_TO_ISO_FORMAT = {
|
||||
shortDate: 'y-MM-dd',
|
||||
}
|
||||
|
||||
const INTERVALS = {
|
||||
year: {
|
||||
label: $localize`%s year ago`,
|
||||
labelPlural: $localize`%s years ago`,
|
||||
interval: 31536000,
|
||||
},
|
||||
month: {
|
||||
label: $localize`%s month ago`,
|
||||
labelPlural: $localize`%s months ago`,
|
||||
interval: 2592000,
|
||||
},
|
||||
week: {
|
||||
label: $localize`%s week ago`,
|
||||
labelPlural: $localize`%s weeks ago`,
|
||||
interval: 604800,
|
||||
},
|
||||
day: {
|
||||
label: $localize`%s day ago`,
|
||||
labelPlural: $localize`%s days ago`,
|
||||
interval: 86400,
|
||||
},
|
||||
hour: {
|
||||
label: $localize`%s hour ago`,
|
||||
labelPlural: $localize`%s hours ago`,
|
||||
interval: 3600,
|
||||
},
|
||||
minute: {
|
||||
label: $localize`%s minute ago`,
|
||||
labelPlural: $localize`%s minutes ago`,
|
||||
interval: 60,
|
||||
},
|
||||
}
|
||||
|
||||
@Pipe({
|
||||
name: 'customDate',
|
||||
})
|
||||
@ -37,45 +70,13 @@ export class CustomDatePipe implements PipeTransform {
|
||||
if (format === 'relative') {
|
||||
const seconds = Math.floor((+new Date() - +new Date(value)) / 1000)
|
||||
if (seconds < 60) return $localize`Just now`
|
||||
const intervals = {
|
||||
year: {
|
||||
label: $localize`year ago`,
|
||||
labelPlural: $localize`years ago`,
|
||||
interval: 31536000,
|
||||
},
|
||||
month: {
|
||||
label: $localize`month ago`,
|
||||
labelPlural: $localize`months ago`,
|
||||
interval: 2592000,
|
||||
},
|
||||
week: {
|
||||
label: $localize`week ago`,
|
||||
labelPlural: $localize`weeks ago`,
|
||||
interval: 604800,
|
||||
},
|
||||
day: {
|
||||
label: $localize`day ago`,
|
||||
labelPlural: $localize`days ago`,
|
||||
interval: 86400,
|
||||
},
|
||||
hour: {
|
||||
label: $localize`hour ago`,
|
||||
labelPlural: $localize`hours ago`,
|
||||
interval: 3600,
|
||||
},
|
||||
minute: {
|
||||
label: $localize`minute ago`,
|
||||
labelPlural: $localize`minutes ago`,
|
||||
interval: 60,
|
||||
},
|
||||
}
|
||||
let counter
|
||||
for (const i in intervals) {
|
||||
counter = Math.floor(seconds / intervals[i].interval)
|
||||
for (const i in INTERVALS) {
|
||||
counter = Math.floor(seconds / INTERVALS[i].interval)
|
||||
if (counter > 0) {
|
||||
const label =
|
||||
counter > 1 ? intervals[i].labelPlural : intervals[i].label
|
||||
return `${counter} ${label}`
|
||||
counter > 1 ? INTERVALS[i].labelPlural : INTERVALS[i].label
|
||||
return label.replace('%s', counter.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user