From: Chocobozzz Date: Mon, 4 Jun 2018 14:21:17 +0000 (+0200) Subject: Add i18n attributes X-Git-Tag: v1.0.0-beta.8~53 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b1d40cff89f7cff565a98cdbcea9a624196a169a;p=oweals%2Fpeertube.git Add i18n attributes --- diff --git a/client/src/app/+accounts/account-about/account-about.component.html b/client/src/app/+accounts/account-about/account-about.component.html index eae1cb509..b178f5cc8 100644 --- a/client/src/app/+accounts/account-about/account-about.component.html +++ b/client/src/app/+accounts/account-about/account-about.component.html @@ -1,12 +1,12 @@
-
Description
+
Description
{{ getAccountDescription() }}
-
Stats
+
Stats
-
Joined {{ account.createdAt | date }}
+
Joined {{ account.createdAt | date }}
\ No newline at end of file diff --git a/client/src/app/+accounts/account-about/account-about.component.ts b/client/src/app/+accounts/account-about/account-about.component.ts index f063df392..4086510ba 100644 --- a/client/src/app/+accounts/account-about/account-about.component.ts +++ b/client/src/app/+accounts/account-about/account-about.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { Account } from '@app/shared/account/account.model' import { AccountService } from '@app/shared/account/account.service' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-account-about', @@ -12,7 +13,8 @@ export class AccountAboutComponent implements OnInit { account: Account constructor ( - protected route: ActivatedRoute, + private route: ActivatedRoute, + private i18n: I18n, private accountService: AccountService ) { } @@ -25,6 +27,6 @@ export class AccountAboutComponent implements OnInit { getAccountDescription () { if (this.account.description) return this.account.description - return 'No description' + return this.i18n('No description') } } diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html index d20b40c60..bcd3beaf0 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html @@ -1,11 +1,11 @@
Avatar
{{ videoChannel.displayName }}
-
{{ videoChannel.followersCount }} subscribers
+
{{ videoChannel.followersCount }} subscribers
\ No newline at end of file diff --git a/client/src/app/+accounts/account-videos/account-videos.component.ts b/client/src/app/+accounts/account-videos/account-videos.component.ts index eca9fb6b7..7b7629480 100644 --- a/client/src/app/+accounts/account-videos/account-videos.component.ts +++ b/client/src/app/+accounts/account-videos/account-videos.component.ts @@ -10,6 +10,7 @@ import { VideoService } from '../../shared/video/video.service' import { Account } from '@app/shared/account/account.model' import { AccountService } from '@app/shared/account/account.service' import { tap } from 'rxjs/operators' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-account-videos', @@ -20,7 +21,7 @@ import { tap } from 'rxjs/operators' ] }) export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { - titlePage = 'Published videos' + titlePage: string marginContent = false // Disable margin currentRoute = '/account/videos' loadOnInit = false @@ -34,10 +35,13 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit, protected notificationsService: NotificationsService, protected confirmService: ConfirmService, protected location: Location, + protected i18n: I18n, private accountService: AccountService, private videoService: VideoService ) { super() + + this.titlePage = this.i18n('Published videos') } ngOnInit () { @@ -63,7 +67,11 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit, return this.videoService .getAccountVideos(this.account, newPagination, this.sort) - .pipe(tap(({ totalVideos }) => this.titlePage = `Published ${totalVideos} videos`)) + .pipe( + tap(({ totalVideos }) => { + this.titlePage = this.i18n('Published {{ totalVideos }} videos', { totalVideos }) + }) + ) } generateSyndicationList () { diff --git a/client/src/app/+accounts/accounts.component.html b/client/src/app/+accounts/accounts.component.html index e872bda03..69f648269 100644 --- a/client/src/app/+accounts/accounts.component.html +++ b/client/src/app/+accounts/accounts.component.html @@ -9,16 +9,16 @@
{{ account.displayName }}
{{ account.nameWithHost }}
-
{{ account.followersCount }} subscribers
+
{{ account.followersCount }} subscribers
diff --git a/client/src/app/+admin/admin.component.html b/client/src/app/+admin/admin.component.html index e4644498b..1b2b89c3a 100644 --- a/client/src/app/+admin/admin.component.html +++ b/client/src/app/+admin/admin.component.html @@ -1,26 +1,26 @@
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index 8a1e33c56..4263b7b5f 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html @@ -4,13 +4,13 @@ -
Instance
+
Instance
- +
{{ formErrors.instanceName }} @@ -18,10 +18,10 @@
- +
{{ formErrors.instanceShortDescription }} @@ -29,10 +29,10 @@
- +
{{ formErrors.instanceDescription }} @@ -40,10 +40,10 @@
- +
{{ formErrors.instanceTerms }} @@ -51,12 +51,12 @@
- +
@@ -65,14 +65,17 @@
- - + +
@@ -80,43 +83,43 @@
-
Signup
+
Signup
- +
- +
{{ formErrors.signupLimit }}
-
Administrator
+
Administrator
- +
{{ formErrors.adminEmail }}
-
Users
+
Users
- +
{{ formErrors.servicesTwitterUsername }} @@ -150,29 +156,32 @@ - - Instance whitelisted by Twitter + +Check this checkbox, save the configuration and test with a video URL of your instance (https://example.com/videos/watch/blabla) on https://cards-dev.twitter.com/validator to see if you instance is whitelisted." + >
-
Transcoding
+
Transcoding
- +
- +
{{ formErrors.cachePreviewsSize }}
-
Customizations
+
Customizations
- - + +
{{ formErrors.customizationJavascript }} @@ -228,25 +243,26 @@ Check this checkbox, save the configuration and test with a video URL of your in
{{ formErrors.customizationCSS }} @@ -255,5 +271,5 @@ Check this checkbox, save the configuration and test with a video URL of your in - + diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index a1e334a74..3f9205460 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -8,12 +8,15 @@ import { FormReactive, USER_VIDEO_QUOTA } from '@app/shared' import { ADMIN_EMAIL, CACHE_PREVIEWS_SIZE, - INSTANCE_NAME, INSTANCE_SHORT_DESCRIPTION, SERVICES_TWITTER_USERNAME, + INSTANCE_NAME, + INSTANCE_SHORT_DESCRIPTION, + SERVICES_TWITTER_USERNAME, SIGNUP_LIMIT, TRANSCODING_THREADS } from '@app/shared/forms/form-validators/custom-config' import { NotificationsService } from 'angular2-notifications' import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-edit-custom-config', @@ -77,7 +80,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { private notificationsService: NotificationsService, private configService: ConfigService, private serverService: ServerService, - private confirmService: ConfirmService + private confirmService: ConfirmService, + private i18n: I18n ) { super() } @@ -133,7 +137,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { this.forceCheck() }, - err => this.notificationsService.error('Error', err.message) + err => this.notificationsService.error(this.i18n('Error'), err.message) ) } @@ -156,11 +160,15 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { if (customizations.length !== 0) { const customizationsText = customizations.join('/') - const message = `You set custom ${customizationsText}. ` + - 'This could lead to security issues or bugs if you do not understand it. ' + - 'Are you sure you want to update the configuration?' - const label = `Please type "I understand the ${customizationsText} I set" to confirm.` - const expectedInputValue = `I understand the ${customizationsText} I set` + // FIXME: i18n service does not support string concatenation + const message = this.i18n('You set custom {{ customizationsText }}. ', { customizationsText }) + + this.i18n('This could lead to security issues or bugs if you do not understand it. ') + + this.i18n('Are you sure you want to update the configuration?') + const label = this.i18n( + 'Please type "I understand the {{ customizationsText }} I set" to confirm.', + { customizationsText } + ) + const expectedInputValue = this.i18n('I understand the {{ customizationsText }} I set', { customizationsText}) const confirmRes = await this.confirmService.confirmWithInput(message, label, expectedInputValue) if (confirmRes === false) return @@ -223,10 +231,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { this.updateForm() - this.notificationsService.success('Success', 'Configuration updated.') + this.notificationsService.success(this.i18n('Success'), this.i18n('Configuration updated.')) }, - err => this.notificationsService.error('Error', err.message) + err => this.notificationsService.error(this.i18n('Error'), err.message) ) } diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.html b/client/src/app/+admin/follows/followers-list/followers-list.component.html index 85d2a2cf6..1a6ed616a 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.html +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.html @@ -4,12 +4,12 @@ > - ID - Score - Name - Host - State - Created + ID + Score + Name + Host + State + Created diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts index 69b3e5e58..96fb67588 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts @@ -5,6 +5,7 @@ import { SortMeta } from 'primeng/primeng' import { AccountFollow } from '../../../../../../shared/models/actors/follow.model' import { RestPagination, RestTable } from '../../../shared' import { FollowService } from '../shared' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-followers-list', @@ -20,7 +21,8 @@ export class FollowersListComponent extends RestTable implements OnInit { constructor ( private notificationsService: NotificationsService, - private followService: FollowService + private followService: FollowService, + private i18n: I18n ) { super() } @@ -37,7 +39,7 @@ export class FollowersListComponent extends RestTable implements OnInit { this.totalRecords = resultList.total }, - err => this.notificationsService.error('Error', err.message) + err => this.notificationsService.error(this.i18n('Error'), err.message) ) } } diff --git a/client/src/app/+admin/follows/following-add/following-add.component.html b/client/src/app/+admin/follows/following-add/following-add.component.html index 25bab9d0d..72635048c 100644 --- a/client/src/app/+admin/follows/following-add/following-add.component.html +++ b/client/src/app/+admin/follows/following-add/following-add.component.html @@ -2,7 +2,7 @@
- + - - + +
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' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { isInSmallView } from '@app/shared/misc/utils' import { MarkdownService } from '@app/videos/shared' -import { Subject } from 'rxjs' +import { Subject } from 'rxjs/Subject' import truncate from 'lodash-es/truncate' @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' import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router' import { Observable } from 'rxjs' import { ConfirmService } from '../../core/index' +import { I18n } from '@ngx-translate/i18n-polyfill' export interface CanComponentDeactivate { canDeactivate: () => { text?: string, canDeactivate: Observable | boolean } @@ -9,7 +10,10 @@ export interface CanComponentDeactivate { @Injectable() export class CanDeactivateGuard implements CanDeactivate { - constructor (private confirmService: ConfirmService) { } + constructor ( + private confirmService: ConfirmService, + private i18n: I18n + ) { } canDeactivate (component: CanComponentDeactivate, currentRoute: ActivatedRouteSnapshot, @@ -17,11 +21,11 @@ export class CanDeactivateGuard implements CanDeactivate nextState: RouterStateSnapshot ) { const result = component.canDeactivate() - const text = result.text || 'All unsaved data will be lost, are you sure you want to leave this page?' + const text = result.text || this.i18n('All unsaved data will be lost, are you sure you want to leave this page?') return result.canDeactivate || this.confirmService.confirm( text, - 'Warning' + this.i18n('Warning') ) } 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 @@ - Edit + Edit 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 @@ import { Pipe, PipeTransform } from '@angular/core' +import { I18n } from '@ngx-translate/i18n-polyfill' // Thanks: https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site @Pipe({ name: 'myFromNow' }) export class FromNowPipe implements PipeTransform { + constructor (private i18n: I18n) { } + transform (value: number) { const seconds = Math.floor((Date.now() - value) / 1000) let interval = Math.floor(seconds / 31536000) if (interval > 1) { - return interval + ' years ago' + return this.i18n('{{ interval }} years ago', { interval }) } interval = Math.floor(seconds / 2592000) - if (interval > 1) return interval + ' months ago' - if (interval === 1) return interval + ' month ago' + if (interval > 1) return this.i18n('{{ interval }} months ago', { interval }) + if (interval === 1) return this.i18n('{{ interval }} month ago', { interval }) interval = Math.floor(seconds / 604800) - if (interval > 1) return interval + ' weeks ago' - if (interval === 1) return interval + ' week ago' + if (interval > 1) return this.i18n('{{ interval }} weeks ago', { interval }) + if (interval === 1) return this.i18n('{{ interval }} week ago', { interval }) interval = Math.floor(seconds / 86400) - if (interval > 1) return interval + ' days ago' - if (interval === 1) return interval + ' day ago' + if (interval > 1) return this.i18n('{{ interval }} days ago', { interval }) + if (interval === 1) return this.i18n('{{ interval }} day ago', { interval }) interval = Math.floor(seconds / 3600) - if (interval > 1) return interval + ' hours ago' - if (interval === 1) return interval + ' hour ago' + if (interval > 1) return this.i18n('{{ interval }} hours ago', { interval }) + if (interval === 1) return this.i18n('{{ interval }} hour ago', { interval }) interval = Math.floor(seconds / 60) - if (interval >= 1) return interval + ' min ago' + if (interval >= 1) return this.i18n('{{ interval }} min ago', { interval }) - return Math.floor(seconds) + ' sec ago' + return this.i18n('{{ interval }} sec ago', { interval: Math.floor(seconds) }) } } 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 @@ -
No results.
+
No results.
{ this.loadingPage[page] = false - this.notificationsService.error('Error', error.message) + this.notificationsService.error(this.i18n('Error'), error.message) } ) } 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 @@ {{ video.name }} - {{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views + {{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views
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 @@ diff --git a/client/src/app/signup/signup.component.html b/client/src/app/signup/signup.component.html index 5f48786e5..2fe9a4281 100644 --- a/client/src/app/signup/signup.component.html +++ b/client/src/app/signup/signup.component.html @@ -1,11 +1,11 @@
-
+
Create an account
- Initial video quota: + Initial video quota: {{ initialUserVideoQuota | bytes: 0 }} @@ -13,18 +13,18 @@ - + Unlimited - +
{{ error }}
- +
@@ -33,9 +33,9 @@
- +
@@ -44,9 +44,9 @@
- +
@@ -54,7 +54,7 @@
- +
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts index 1f3e2e146..4a49ead50 100644 --- a/client/src/app/signup/signup.component.ts +++ b/client/src/app/signup/signup.component.ts @@ -6,6 +6,8 @@ import { ServerService } from '@app/core/server' import { NotificationsService } from 'angular2-notifications' import { UserCreate } from '../../../../shared' import { FormReactive, USER_EMAIL, USER_PASSWORD, USER_USERNAME, UserService } from '../shared' +import { RedirectService } from '@app/core' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-signup', @@ -45,7 +47,9 @@ export class SignupComponent extends FormReactive implements OnInit { private router: Router, private notificationsService: NotificationsService, private userService: UserService, - private serverService: ServerService + private redirectService: RedirectService, + private serverService: ServerService, + private i18n: I18n ) { super() } @@ -78,8 +82,11 @@ export class SignupComponent extends FormReactive implements OnInit { this.userService.signup(userCreate).subscribe( () => { - this.notificationsService.success('Success', `Registration for ${userCreate.username} complete.`) - this.router.navigate([ '/videos/list' ]) + this.notificationsService.success( + this.i18n('Success'), + this.i18n('Registration for {{ username }} complete.', { username: userCreate.username}) + ) + this.redirectService.redirectToHomepage() }, err => this.error = err.message @@ -99,9 +106,9 @@ export class SignupComponent extends FormReactive implements OnInit { const normalSeconds = initialUserVideoQuotaBit / (1.5 * 1000 * 1000) const lines = [ - SignupComponent.getApproximateTime(fullHdSeconds) + ' of full HD videos', - SignupComponent.getApproximateTime(hdSeconds) + ' of HD videos', - SignupComponent.getApproximateTime(normalSeconds) + ' of average quality videos' + this.i18n('{{ seconds }} of full HD videos', { seconds: SignupComponent.getApproximateTime(fullHdSeconds) }), + this.i18n('{{ seconds }} of HD videos', { seconds: SignupComponent.getApproximateTime(hdSeconds) }), + this.i18n('{{ seconds }} of average quality videos', { seconds: SignupComponent.getApproximateTime(normalSeconds) }) ] this.quotaHelpIndication = lines.join('
') diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.html b/client/src/app/videos/+video-edit/shared/video-edit.component.html index 7e1be4467..bd9f69362 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.html +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.html @@ -4,7 +4,7 @@
- +
{{ formErrors.name }} @@ -12,7 +12,7 @@
- (press Enter to add) + (press Enter to add)
- - + +
@@ -32,7 +32,7 @@
- +
@@ -55,7 +55,7 @@
- +
@@ -83,7 +83,7 @@
- +
- - + +
- +
@@ -116,24 +116,24 @@
- - + +
{{ formErrors.support }} diff --git a/client/src/app/videos/+video-edit/shared/video-image.component.html b/client/src/app/videos/+video-edit/shared/video-image.component.html index 5d0624f8c..e319d7ee7 100644 --- a/client/src/app/videos/+video-edit/shared/video-image.component.html +++ b/client/src/app/videos/+video-edit/shared/video-image.component.html @@ -8,7 +8,7 @@ (change)="fileChange($event)" />
-
(extensions: {{ videoImageExtensions }}, max size: {{ maxVideoImageSize | bytes }})
+
(extensions: {{ videoImageExtensions }}, max size: {{ maxVideoImageSize | bytes }})
diff --git a/client/src/app/videos/+video-edit/video-add.component.html b/client/src/app/videos/+video-edit/video-add.component.html index 440556562..f00cfe016 100644 --- a/client/src/app/videos/+video-edit/video-add.component.html +++ b/client/src/app/videos/+video-edit/video-add.component.html @@ -1,7 +1,7 @@
- Upload your video - Upload {{ videoFileName }} + Upload your video + Upload {{ videoFileName }}
@@ -9,12 +9,12 @@
- Select the file to upload + Select the file to upload
- +
@@ -49,14 +49,14 @@ >
-
Publish will be available when upload is finished
+
Publish will be available when upload is finished
- +
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index 997f033b7..a615fd92c 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts @@ -15,6 +15,7 @@ import { ValidatorMessage } from '../../shared/forms/form-validators/validator-m import { populateAsyncUserVideoChannels } from '../../shared/misc/utils' import { VideoEdit } from '../../shared/video/video-edit.model' import { VideoService } from '../../shared/video/video.service' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-videos-add', @@ -56,7 +57,8 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy private userService: UserService, private serverService: ServerService, private videoService: VideoService, - private loadingBar: LoadingBarService + private loadingBar: LoadingBarService, + private i18n: I18n ) { super() } @@ -99,10 +101,11 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy let text = '' if (this.videoUploaded === true) { - text = 'Your video was uploaded in your account and is private.' + - ' But associated data (tags, description...) will be lost, are you sure you want to leave this page?' + // FIXME: cannot concatenate strings inside i18n service :/ + text = this.i18n('Your video was uploaded in your account and is private.') + + this.i18n('But associated data (tags, description...) will be lost, are you sure you want to leave this page?') } else { - text = 'Your video is not uploaded yet, are you sure you want to leave this page?' + text = this.i18n('Your video is not uploaded yet, are you sure you want to leave this page?') } return { @@ -127,7 +130,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy this.isUploadingVideo = false this.videoUploadPercents = 0 this.videoUploadObservable = null - this.notificationsService.info('Info', 'Upload cancelled') + this.notificationsService.info(this.i18n('Info'), this.i18n('Upload cancelled')) } } @@ -137,7 +140,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy // Cannot upload videos > 4GB for now if (videofile.size > 4 * 1024 * 1024 * 1024) { - this.notificationsService.error('Error', 'We are sorry but PeerTube cannot handle videos > 4GB') + this.notificationsService.error(this.i18n('Error'), this.i18n('We are sorry but PeerTube cannot handle videos > 4GB')) return } @@ -145,11 +148,15 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy if (videoQuota !== -1 && (this.userVideoQuotaUsed + videofile.size) > videoQuota) { const bytePipes = new BytesPipe() - const msg = 'Your video quota is exceeded with this video ' + - `(video size: ${bytePipes.transform(videofile.size, 0)}, ` + - `used: ${bytePipes.transform(this.userVideoQuotaUsed, 0)}, ` + - `quota: ${bytePipes.transform(videoQuota, 0)})` - this.notificationsService.error('Error', msg) + const msg = this.i18n( + 'Your video quota is exceeded with this video (video size: {{ videoSize }}, used: {{ videoQuotaUsed }}, quota: {{ videoQuota }})', + { + videoSize: bytePipes.transform(videofile.size, 0), + videoQuotaUsed: bytePipes.transform(this.userVideoQuotaUsed, 0), + videoQuota: bytePipes.transform(videoQuota, 0) + } + ) + this.notificationsService.error(this.i18n('Error'), msg) return } @@ -192,8 +199,6 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy if (event.type === HttpEventType.UploadProgress) { this.videoUploadPercents = Math.round(100 * event.loaded / event.total) } else if (event instanceof HttpResponse) { - console.log('Video uploaded.') - this.videoUploaded = true this.videoUploadedIds = event.body.video @@ -207,7 +212,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy this.isUploadingVideo = false this.videoUploadPercents = 0 this.videoUploadObservable = null - this.notificationsService.error('Error', err.message) + this.notificationsService.error(this.i18n('Error'), err.message) } ) } @@ -231,13 +236,13 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy this.isUploadingVideo = false this.loadingBar.complete() - this.notificationsService.success('Success', 'Video published.') + this.notificationsService.success(this.i18n('Success'), this.i18n('Video published.')) this.router.navigate([ '/videos/watch', video.uuid ]) }, err => { this.isUpdatingVideo = false - this.notificationsService.error('Error', err.message) + this.notificationsService.error(this.i18n('Error'), err.message) console.error(err) } ) diff --git a/client/src/app/videos/+video-edit/video-update.component.html b/client/src/app/videos/+video-edit/video-update.component.html index a1b4707be..73b2bc08f 100644 --- a/client/src/app/videos/+video-edit/video-update.component.html +++ b/client/src/app/videos/+video-edit/video-update.component.html @@ -1,5 +1,5 @@
-
+
Update {{ video?.name }}
@@ -13,7 +13,7 @@
- +
diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index 310285f92..e37dd526f 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts @@ -12,6 +12,7 @@ import { ValidatorMessage } from '../../shared/forms/form-validators/validator-m import { VideoEdit } from '../../shared/video/video-edit.model' import { VideoService } from '../../shared/video/video.service' import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-videos-update', @@ -37,7 +38,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { private videoService: VideoService, private authService: AuthService, private loadingBar: LoadingBarService, - private videoChannelService: VideoChannelService + private videoChannelService: VideoChannelService, + private i18n: I18n ) { super() } @@ -91,7 +93,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { err => { console.error(err) - this.notificationsService.error('Error', err.message) + this.notificationsService.error(this.i18n('Error'), err.message) } ) } @@ -116,13 +118,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { () => { this.isUpdatingVideo = false this.loadingBar.complete() - this.notificationsService.success('Success', 'Video updated.') + this.notificationsService.success(this.i18n('Success'), this.i18n('Video updated.')) this.router.navigate([ '/videos/watch', this.video.uuid ]) }, err => { this.isUpdatingVideo = false - this.notificationsService.error('Error', err.message) + this.notificationsService.error(this.i18n('Error'), err.message) console.error(err) } ) diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html index 54d7286db..eaf068cfa 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html @@ -3,7 +3,7 @@ Avatar
- @@ -14,7 +14,7 @@
-
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index b1f446475..2ee5f5ef1 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts @@ -9,6 +9,7 @@ import { User } from '../../../shared/users' import { Video } from '../../../shared/video/video.model' import { VideoComment } from './video-comment.model' import { VideoCommentService } from './video-comment.service' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-video-comment-add', @@ -37,7 +38,8 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { constructor ( private formBuilder: FormBuilder, private notificationsService: NotificationsService, - private videoCommentService: VideoCommentService + private videoCommentService: VideoCommentService, + private i18n: I18n ) { super() } @@ -92,7 +94,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { this.form.reset() }, - err => this.notificationsService.error('Error', err.text) + err => this.notificationsService.error(this.i18n('Error'), err.text) ) } diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html index 06808ef80..60b803206 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html @@ -2,7 +2,7 @@ Avatar
-
Highlighted comment
+
Highlighted comment
- +
@@ -14,7 +17,7 @@ (commentCreated)="onCommentThreadCreated($event)" > -
No comments.
+
No comments.
@@ -50,7 +53,7 @@ >
- View all {{ comment.totalReplies }} replies + View all {{ comment.totalReplies }} replies @@ -59,7 +62,7 @@
-
+
Comments are disabled.
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index 34f4a0701..8c6ddb89e 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts @@ -11,6 +11,7 @@ import { VideoSortField } from '../../../shared/video/sort-field.type' import { VideoDetails } from '../../../shared/video/video-details.model' import { VideoComment } from './video-comment.model' import { VideoCommentService } from './video-comment.service' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-video-comments', @@ -40,7 +41,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { private notificationsService: NotificationsService, private confirmService: ConfirmService, private videoCommentService: VideoCommentService, - private activatedRoute: ActivatedRoute + private activatedRoute: ActivatedRoute, + private i18n: I18n ) {} ngOnInit () { @@ -77,7 +79,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { if (highlightThread) this.highlightedThread = new VideoComment(res.comment) }, - err => this.notificationsService.error('Error', err.message) + err => this.notificationsService.error(this.i18n('Error'), err.message) ) } @@ -89,7 +91,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { this.componentPagination.totalItems = res.totalComments }, - err => this.notificationsService.error('Error', err.message) + err => this.notificationsService.error(this.i18n('Error'), err.message) ) } @@ -111,9 +113,11 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { async onWantedToDelete (commentToDelete: VideoComment) { let message = 'Do you really want to delete this comment?' - if (commentToDelete.totalReplies !== 0) message += `${commentToDelete.totalReplies} would be deleted too.` + if (commentToDelete.totalReplies !== 0) { + message += this.i18n(' {{ totalReplies }} replies will be deleted too.', { totalReplies: commentToDelete.totalReplies }) + } - const res = await this.confirmService.confirm(message, 'Delete') + const res = await this.confirmService.confirm(message, this.i18n('Delete')) if (res === false) return this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id) @@ -136,7 +140,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { this.componentPagination.totalItems-- }, - err => this.notificationsService.error('Error', err.message) + err => this.notificationsService.error(this.i18n('Error'), err.message) ) } diff --git a/client/src/app/videos/+video-watch/modal/video-download.component.html b/client/src/app/videos/+video-watch/modal/video-download.component.html index 617892b11..d30a49345 100644 --- a/client/src/app/videos/+video-watch/modal/video-download.component.html +++ b/client/src/app/videos/+video-watch/modal/video-download.component.html @@ -4,7 +4,7 @@