aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/misc
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-04 16:21:17 +0200
committerChocobozzz <me@florianbigard.com>2018-06-05 08:43:01 +0200
commitb1d40cff89f7cff565a98cdbcea9a624196a169a (patch)
treed24746c1cc69f50471a9eba0dfb1c1bae06a1870 /client/src/app/shared/misc
parent989e526abf0c0dd7958deb630df009608561bb67 (diff)
downloadPeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.gz
PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.zst
PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.zip
Add i18n attributes
Diffstat (limited to 'client/src/app/shared/misc')
-rw-r--r--client/src/app/shared/misc/edit-button.component.html2
-rw-r--r--client/src/app/shared/misc/from-now.pipe.ts25
-rw-r--r--client/src/app/shared/misc/help.component.html1
3 files changed, 16 insertions, 12 deletions
diff --git a/client/src/app/shared/misc/edit-button.component.html b/client/src/app/shared/misc/edit-button.component.html
index 632d6bba2..78fbc326e 100644
--- a/client/src/app/shared/misc/edit-button.component.html
+++ b/client/src/app/shared/misc/edit-button.component.html
@@ -1,4 +1,4 @@
1<a class="action-button action-button-edit" [routerLink]="routerLink" title="Edit"> 1<a class="action-button action-button-edit" [routerLink]="routerLink" title="Edit">
2 <span class="icon icon-edit"></span> 2 <span class="icon icon-edit"></span>
3 <span class="button-label">Edit</span> 3 <span i18n class="button-label">Edit</span>
4</a> 4</a>
diff --git a/client/src/app/shared/misc/from-now.pipe.ts b/client/src/app/shared/misc/from-now.pipe.ts
index fac02af0b..3a64a4077 100644
--- a/client/src/app/shared/misc/from-now.pipe.ts
+++ b/client/src/app/shared/misc/from-now.pipe.ts
@@ -1,36 +1,39 @@
1import { Pipe, PipeTransform } from '@angular/core' 1import { Pipe, PipeTransform } from '@angular/core'
2import { I18n } from '@ngx-translate/i18n-polyfill'
2 3
3// Thanks: https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site 4// Thanks: https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site
4@Pipe({ name: 'myFromNow' }) 5@Pipe({ name: 'myFromNow' })
5export class FromNowPipe implements PipeTransform { 6export class FromNowPipe implements PipeTransform {
6 7
8 constructor (private i18n: I18n) { }
9
7 transform (value: number) { 10 transform (value: number) {
8 const seconds = Math.floor((Date.now() - value) / 1000) 11 const seconds = Math.floor((Date.now() - value) / 1000)
9 12
10 let interval = Math.floor(seconds / 31536000) 13 let interval = Math.floor(seconds / 31536000)
11 if (interval > 1) { 14 if (interval > 1) {
12 return interval + ' years ago' 15 return this.i18n('{{ interval }} years ago', { interval })
13 } 16 }
14 17
15 interval = Math.floor(seconds / 2592000) 18 interval = Math.floor(seconds / 2592000)
16 if (interval > 1) return interval + ' months ago' 19 if (interval > 1) return this.i18n('{{ interval }} months ago', { interval })
17 if (interval === 1) return interval + ' month ago' 20 if (interval === 1) return this.i18n('{{ interval }} month ago', { interval })
18 21
19 interval = Math.floor(seconds / 604800) 22 interval = Math.floor(seconds / 604800)
20 if (interval > 1) return interval + ' weeks ago' 23 if (interval > 1) return this.i18n('{{ interval }} weeks ago', { interval })
21 if (interval === 1) return interval + ' week ago' 24 if (interval === 1) return this.i18n('{{ interval }} week ago', { interval })
22 25
23 interval = Math.floor(seconds / 86400) 26 interval = Math.floor(seconds / 86400)
24 if (interval > 1) return interval + ' days ago' 27 if (interval > 1) return this.i18n('{{ interval }} days ago', { interval })
25 if (interval === 1) return interval + ' day ago' 28 if (interval === 1) return this.i18n('{{ interval }} day ago', { interval })
26 29
27 interval = Math.floor(seconds / 3600) 30 interval = Math.floor(seconds / 3600)
28 if (interval > 1) return interval + ' hours ago' 31 if (interval > 1) return this.i18n('{{ interval }} hours ago', { interval })
29 if (interval === 1) return interval + ' hour ago' 32 if (interval === 1) return this.i18n('{{ interval }} hour ago', { interval })
30 33
31 interval = Math.floor(seconds / 60) 34 interval = Math.floor(seconds / 60)
32 if (interval >= 1) return interval + ' min ago' 35 if (interval >= 1) return this.i18n('{{ interval }} min ago', { interval })
33 36
34 return Math.floor(seconds) + ' sec ago' 37 return this.i18n('{{ interval }} sec ago', { interval: Math.floor(seconds) })
35 } 38 }
36} 39}
diff --git a/client/src/app/shared/misc/help.component.html b/client/src/app/shared/misc/help.component.html
index 3da5701a0..f2b6eca33 100644
--- a/client/src/app/shared/misc/help.component.html
+++ b/client/src/app/shared/misc/help.component.html
@@ -15,6 +15,7 @@
15<span 15<span
16 class="help-tooltip-button" 16 class="help-tooltip-button"
17 title="Get help" 17 title="Get help"
18 i18n-title
18 [popover]="tooltipTemplate" 19 [popover]="tooltipTemplate"
19 [placement]="tooltipPlacement" 20 [placement]="tooltipPlacement"
20 [outsideClick]="true" 21 [outsideClick]="true"