aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
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
parent989e526abf0c0dd7958deb630df009608561bb67 (diff)
downloadPeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.gz
PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.zst
PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.zip
Add i18n attributes
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/forms/markdown-textarea.component.html4
-rw-r--r--client/src/app/shared/forms/markdown-textarea.component.ts2
-rw-r--r--client/src/app/shared/guards/can-deactivate-guard.service.ts10
-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
-rw-r--r--client/src/app/shared/rest/rest-extractor.service.ts16
-rw-r--r--client/src/app/shared/video/abstract-video-list.html2
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts4
-rw-r--r--client/src/app/shared/video/video-miniature.component.html2
-rw-r--r--client/src/app/shared/video/video-thumbnail.component.html2
11 files changed, 43 insertions, 27 deletions
diff --git a/client/src/app/shared/forms/markdown-textarea.component.html b/client/src/app/shared/forms/markdown-textarea.component.html
index 46a97b163..6effda5b8 100644
--- a/client/src/app/shared/forms/markdown-textarea.component.html
+++ b/client/src/app/shared/forms/markdown-textarea.component.html
@@ -6,7 +6,7 @@
6 </textarea> 6 </textarea>
7 7
8 <tabset *ngIf="arePreviewsDisplayed()" class="previews"> 8 <tabset *ngIf="arePreviewsDisplayed()" class="previews">
9 <tab *ngIf="truncate !== undefined" heading="Truncated preview" [innerHTML]="truncatedPreviewHTML"></tab> 9 <tab *ngIf="truncate !== undefined" i18n-heading heading="Truncated preview" [innerHTML]="truncatedPreviewHTML"></tab>
10 <tab heading="Complete preview" [innerHTML]="previewHTML"></tab> 10 <tab i18n-heading heading="Complete preview" [innerHTML]="previewHTML"></tab>
11 </tabset> 11 </tabset>
12</div> 12</div>
diff --git a/client/src/app/shared/forms/markdown-textarea.component.ts b/client/src/app/shared/forms/markdown-textarea.component.ts
index dcc85f3cd..8b932cd15 100644
--- a/client/src/app/shared/forms/markdown-textarea.component.ts
+++ b/client/src/app/shared/forms/markdown-textarea.component.ts
@@ -3,7 +3,7 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core'
3import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' 3import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
4import { isInSmallView } from '@app/shared/misc/utils' 4import { isInSmallView } from '@app/shared/misc/utils'
5import { MarkdownService } from '@app/videos/shared' 5import { MarkdownService } from '@app/videos/shared'
6import { Subject } from 'rxjs' 6import { Subject } from 'rxjs/Subject'
7import truncate from 'lodash-es/truncate' 7import truncate from 'lodash-es/truncate'
8 8
9@Component({ 9@Component({
diff --git a/client/src/app/shared/guards/can-deactivate-guard.service.ts b/client/src/app/shared/guards/can-deactivate-guard.service.ts
index 550dd656e..c038a5c0e 100644
--- a/client/src/app/shared/guards/can-deactivate-guard.service.ts
+++ b/client/src/app/shared/guards/can-deactivate-guard.service.ts
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router' 2import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router'
3import { Observable } from 'rxjs' 3import { Observable } from 'rxjs'
4import { ConfirmService } from '../../core/index' 4import { ConfirmService } from '../../core/index'
5import { I18n } from '@ngx-translate/i18n-polyfill'
5 6
6export interface CanComponentDeactivate { 7export interface CanComponentDeactivate {
7 canDeactivate: () => { text?: string, canDeactivate: Observable<boolean> | boolean } 8 canDeactivate: () => { text?: string, canDeactivate: Observable<boolean> | boolean }
@@ -9,7 +10,10 @@ export interface CanComponentDeactivate {
9 10
10@Injectable() 11@Injectable()
11export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> { 12export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> {
12 constructor (private confirmService: ConfirmService) { } 13 constructor (
14 private confirmService: ConfirmService,
15 private i18n: I18n
16 ) { }
13 17
14 canDeactivate (component: CanComponentDeactivate, 18 canDeactivate (component: CanComponentDeactivate,
15 currentRoute: ActivatedRouteSnapshot, 19 currentRoute: ActivatedRouteSnapshot,
@@ -17,11 +21,11 @@ export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate>
17 nextState: RouterStateSnapshot 21 nextState: RouterStateSnapshot
18 ) { 22 ) {
19 const result = component.canDeactivate() 23 const result = component.canDeactivate()
20 const text = result.text || 'All unsaved data will be lost, are you sure you want to leave this page?' 24 const text = result.text || this.i18n('All unsaved data will be lost, are you sure you want to leave this page?')
21 25
22 return result.canDeactivate || this.confirmService.confirm( 26 return result.canDeactivate || this.confirmService.confirm(
23 text, 27 text,
24 'Warning' 28 this.i18n('Warning')
25 ) 29 )
26 } 30 }
27 31
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"
diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts
index 39e601e20..468ac3e32 100644
--- a/client/src/app/shared/rest/rest-extractor.service.ts
+++ b/client/src/app/shared/rest/rest-extractor.service.ts
@@ -3,11 +3,15 @@ import { Injectable } from '@angular/core'
3import { dateToHuman } from '@app/shared/misc/utils' 3import { dateToHuman } from '@app/shared/misc/utils'
4import { ResultList } from '../../../../../shared' 4import { ResultList } from '../../../../../shared'
5import { Router } from '@angular/router' 5import { Router } from '@angular/router'
6import { I18n } from '@ngx-translate/i18n-polyfill'
6 7
7@Injectable() 8@Injectable()
8export class RestExtractor { 9export class RestExtractor {
9 10
10 constructor (private router: Router) { 11 constructor (
12 private router: Router,
13 private i18n: I18n
14 ) {
11 // empty 15 // empty
12 } 16 }
13 17
@@ -60,17 +64,19 @@ export class RestExtractor {
60 } else if (err.error && err.error.error) { 64 } else if (err.error && err.error.error) {
61 errorMessage = err.error.error 65 errorMessage = err.error.error
62 } else if (err.status === 413) { 66 } else if (err.status === 413) {
63 errorMessage = 'Request is too large for the server. Please contact you administrator if you want to increase the limit size.' 67 errorMessage = this.i18n(
68 'Request is too large for the server. Please contact you administrator if you want to increase the limit size.'
69 )
64 } else if (err.status === 429) { 70 } else if (err.status === 429) {
65 const secondsLeft = err.headers.get('retry-after') 71 const secondsLeft = err.headers.get('retry-after')
66 if (secondsLeft) { 72 if (secondsLeft) {
67 const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60) 73 const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60)
68 errorMessage = 'Too many attempts, please try again after ' + minutesLeft + ' minutes.' 74 errorMessage = this.i18n('Too many attempts, please try again after {{ minutesLeft }} minutes.', { minutesLeft })
69 } else { 75 } else {
70 errorMessage = 'Too many attempts, please try again later.' 76 errorMessage = this.i18n('Too many attempts, please try again later.')
71 } 77 }
72 } else if (err.status === 500) { 78 } else if (err.status === 500) {
73 errorMessage = 'Server error. Please retry later.' 79 errorMessage = this.i18n('Server error. Please retry later.')
74 } 80 }
75 81
76 errorMessage = errorMessage ? errorMessage : 'Unknown error.' 82 errorMessage = errorMessage ? errorMessage : 'Unknown error.'
diff --git a/client/src/app/shared/video/abstract-video-list.html b/client/src/app/shared/video/abstract-video-list.html
index 690529dcf..e8ded6ab8 100644
--- a/client/src/app/shared/video/abstract-video-list.html
+++ b/client/src/app/shared/video/abstract-video-list.html
@@ -4,7 +4,7 @@
4 </div> 4 </div>
5 <my-video-feed [syndicationItems]="syndicationItems"></my-video-feed> 5 <my-video-feed [syndicationItems]="syndicationItems"></my-video-feed>
6 6
7 <div *ngIf="pagination.totalItems === 0">No results.</div> 7 <div i18n *ngIf="pagination.totalItems === 0">No results.</div>
8 <div 8 <div
9 myInfiniteScroller 9 myInfiniteScroller
10 [pageHeight]="pageHeight" 10 [pageHeight]="pageHeight"
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts
index 100cbff8d..1c84573da 100644
--- a/client/src/app/shared/video/abstract-video-list.ts
+++ b/client/src/app/shared/video/abstract-video-list.ts
@@ -10,6 +10,7 @@ import { AuthService } from '../../core/auth'
10import { ComponentPagination } from '../rest/component-pagination.model' 10import { ComponentPagination } from '../rest/component-pagination.model'
11import { VideoSortField } from './sort-field.type' 11import { VideoSortField } from './sort-field.type'
12import { Video } from './video.model' 12import { Video } from './video.model'
13import { I18n } from '@ngx-translate/i18n-polyfill'
13 14
14export abstract class AbstractVideoList implements OnInit, OnDestroy { 15export abstract class AbstractVideoList implements OnInit, OnDestroy {
15 private static LINES_PER_PAGE = 4 16 private static LINES_PER_PAGE = 4
@@ -40,6 +41,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
40 protected abstract authService: AuthService 41 protected abstract authService: AuthService
41 protected abstract router: Router 42 protected abstract router: Router
42 protected abstract route: ActivatedRoute 43 protected abstract route: ActivatedRoute
44 protected abstract i18n: I18n
43 protected abstract location: Location 45 protected abstract location: Location
44 protected abstract currentRoute: string 46 protected abstract currentRoute: string
45 abstract titlePage: string 47 abstract titlePage: string
@@ -124,7 +126,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
124 }, 126 },
125 error => { 127 error => {
126 this.loadingPage[page] = false 128 this.loadingPage[page] = false
127 this.notificationsService.error('Error', error.message) 129 this.notificationsService.error(this.i18n('Error'), error.message)
128 } 130 }
129 ) 131 )
130 } 132 }
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html
index 09ce0ef7f..3010e5ccc 100644
--- a/client/src/app/shared/video/video-miniature.component.html
+++ b/client/src/app/shared/video/video-miniature.component.html
@@ -9,7 +9,7 @@
9 {{ video.name }} 9 {{ video.name }}
10 </a> 10 </a>
11 11
12 <span class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> 12 <span i18n class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span>
13 <a class="video-miniature-account" [routerLink]="[ '/accounts', video.by ]">{{ video.by }}</a> 13 <a class="video-miniature-account" [routerLink]="[ '/accounts', video.by ]">{{ video.by }}</a>
14 </div> 14 </div>
15</div> 15</div>
diff --git a/client/src/app/shared/video/video-thumbnail.component.html b/client/src/app/shared/video/video-thumbnail.component.html
index 4604d10e2..971f352ba 100644
--- a/client/src/app/shared/video/video-thumbnail.component.html
+++ b/client/src/app/shared/video/video-thumbnail.component.html
@@ -1,6 +1,6 @@
1<a 1<a
2 [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" 2 [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name"
3class="video-thumbnail" 3 class="video-thumbnail"
4> 4>
5<img [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" /> 5<img [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" />
6 6