aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-settings
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-12 10:40:04 +0200
committerChocobozzz <me@florianbigard.com>2020-08-14 10:28:30 +0200
commit66357162f8e1227495f09bd4f68446aad7071c6d (patch)
tree7d4429506deb512b2fe1d0267f38a28cda20af55 /client/src/app/+my-account/my-account-settings
parent8c360747995e17eb5520e22fc3d7bd4c3d26eeee (diff)
downloadPeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.gz
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.zst
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.zip
Migrate to $localize
* Remove i18n polyfill to translate things in components * Reduce bundle sizes * Improve runtime perf * Reduce a lot the time to make a full client build * Reduce client build complexity * We don't need a service to translate things anymore (so we will be able to translate title pages etc) Unfortunately we may loose some translations in the migration process. I'll put a message on weblate to notify translators
Diffstat (limited to 'client/src/app/+my-account/my-account-settings')
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts12
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts10
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts16
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts32
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts8
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-settings.component.ts8
6 files changed, 37 insertions, 49 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
index 5444b97ae..396936ef3 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
@@ -3,7 +3,6 @@ import { tap } from 'rxjs/operators'
3import { Component, OnInit } from '@angular/core' 3import { Component, OnInit } from '@angular/core'
4import { AuthService, ServerService, UserService } from '@app/core' 4import { AuthService, ServerService, UserService } from '@app/core'
5import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 5import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { User } from '@shared/models' 6import { User } from '@shared/models'
8 7
9@Component({ 8@Component({
@@ -21,9 +20,8 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
21 private userValidatorsService: UserValidatorsService, 20 private userValidatorsService: UserValidatorsService,
22 private authService: AuthService, 21 private authService: AuthService,
23 private userService: UserService, 22 private userService: UserService,
24 private serverService: ServerService, 23 private serverService: ServerService
25 private i18n: I18n 24 ) {
26 ) {
27 super() 25 super()
28 } 26 }
29 27
@@ -52,15 +50,15 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
52 this.form.reset() 50 this.form.reset()
53 51
54 if (config.signup.requiresEmailVerification) { 52 if (config.signup.requiresEmailVerification) {
55 this.success = this.i18n('Please check your emails to verify your new email.') 53 this.success = $localize`Please check your emails to verify your new email.`
56 } else { 54 } else {
57 this.success = this.i18n('Email updated.') 55 this.success = $localize`Email updated.`
58 } 56 }
59 }, 57 },
60 58
61 err => { 59 err => {
62 if (err.status === 401) { 60 if (err.status === 401) {
63 this.error = this.i18n('You current password is invalid.') 61 this.error = $localize`You current password is invalid.`
64 return 62 return
65 } 63 }
66 64
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
index 6a16f8a2c..91fe4ec72 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
@@ -2,7 +2,6 @@ import { filter } from 'rxjs/operators'
2import { Component, OnInit } from '@angular/core' 2import { Component, OnInit } from '@angular/core'
3import { AuthService, Notifier, UserService } from '@app/core' 3import { AuthService, Notifier, UserService } from '@app/core'
4import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 4import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { User } from '@shared/models' 5import { User } from '@shared/models'
7 6
8@Component({ 7@Component({
@@ -19,9 +18,8 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
19 private userValidatorsService: UserValidatorsService, 18 private userValidatorsService: UserValidatorsService,
20 private notifier: Notifier, 19 private notifier: Notifier,
21 private authService: AuthService, 20 private authService: AuthService,
22 private userService: UserService, 21 private userService: UserService
23 private i18n: I18n 22 ) {
24 ) {
25 super() 23 super()
26 } 24 }
27 25
@@ -47,7 +45,7 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
47 45
48 this.userService.changePassword(currentPassword, newPassword).subscribe( 46 this.userService.changePassword(currentPassword, newPassword).subscribe(
49 () => { 47 () => {
50 this.notifier.success(this.i18n('Password updated.')) 48 this.notifier.success($localize`Password updated.`)
51 49
52 this.form.reset() 50 this.form.reset()
53 this.error = null 51 this.error = null
@@ -55,7 +53,7 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
55 53
56 err => { 54 err => {
57 if (err.status === 401) { 55 if (err.status === 401) {
58 this.error = this.i18n('You current password is invalid.') 56 this.error = $localize`You current password is invalid.`
59 return 57 return
60 } 58 }
61 59
diff --git a/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts
index ae6ac5387..387e9e7cd 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts
@@ -1,6 +1,5 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input } from '@angular/core'
2import { AuthService, ConfirmService, Notifier, RedirectService, User, UserService } from '@app/core' 2import { AuthService, ConfirmService, Notifier, RedirectService, User, UserService } from '@app/core'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4 3
5@Component({ 4@Component({
6 selector: 'my-account-danger-zone', 5 selector: 'my-account-danger-zone',
@@ -15,23 +14,22 @@ export class MyAccountDangerZoneComponent {
15 private notifier: Notifier, 14 private notifier: Notifier,
16 private userService: UserService, 15 private userService: UserService,
17 private confirmService: ConfirmService, 16 private confirmService: ConfirmService,
18 private redirectService: RedirectService, 17 private redirectService: RedirectService
19 private i18n: I18n 18 ) { }
20 ) { }
21 19
22 async deleteMe () { 20 async deleteMe () {
23 const res = await this.confirmService.confirmWithInput( 21 const res = await this.confirmService.confirmWithInput(
24 this.i18n('Are you sure you want to delete your account? This will delete all your data, including channels, videos and comments. Content cached by other servers and other third-parties might make longer to be deleted.'), 22 $localize`Are you sure you want to delete your account? This will delete all your data, including channels, videos and comments. Content cached by other servers and other third-parties might make longer to be deleted.`,
25 this.i18n('Type your username to confirm'), 23 $localize`Type your username to confirm`,
26 this.user.username, 24 this.user.username,
27 this.i18n('Delete your account'), 25 $localize`Delete your account`,
28 this.i18n('Delete my account') 26 $localize`Delete my account`
29 ) 27 )
30 if (res === false) return 28 if (res === false) return
31 29
32 this.userService.deleteMe().subscribe( 30 this.userService.deleteMe().subscribe(
33 () => { 31 () => {
34 this.notifier.success(this.i18n('Your account is deleted.')) 32 this.notifier.success($localize`Your account is deleted.`)
35 33
36 this.authService.logout() 34 this.authService.logout()
37 this.redirectService.redirectToHomepage() 35 this.redirectService.redirectToHomepage()
diff --git a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts
index b892ab479..bcbea7fad 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts
@@ -3,7 +3,6 @@ import { Subject } from 'rxjs'
3import { Component, Input, OnInit } from '@angular/core' 3import { Component, Input, OnInit } from '@angular/core'
4import { Notifier, ServerService, User } from '@app/core' 4import { Notifier, ServerService, User } from '@app/core'
5import { UserNotificationService } from '@app/shared/shared-main' 5import { UserNotificationService } from '@app/shared/shared-main'
6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { UserNotificationSetting, UserNotificationSettingValue, UserRight } from '@shared/models' 6import { UserNotificationSetting, UserNotificationSettingValue, UserRight } from '@shared/models'
8 7
9@Component({ 8@Component({
@@ -25,26 +24,25 @@ export class MyAccountNotificationPreferencesComponent implements OnInit {
25 private savePreferences = debounce(this.savePreferencesImpl.bind(this), 500) 24 private savePreferences = debounce(this.savePreferencesImpl.bind(this), 500)
26 25
27 constructor ( 26 constructor (
28 private i18n: I18n,
29 private userNotificationService: UserNotificationService, 27 private userNotificationService: UserNotificationService,
30 private serverService: ServerService, 28 private serverService: ServerService,
31 private notifier: Notifier 29 private notifier: Notifier
32 ) { 30 ) {
33 this.labelNotifications = { 31 this.labelNotifications = {
34 newVideoFromSubscription: this.i18n('New video from your subscriptions'), 32 newVideoFromSubscription: $localize`New video from your subscriptions`,
35 newCommentOnMyVideo: this.i18n('New comment on your video'), 33 newCommentOnMyVideo: $localize`New comment on your video`,
36 abuseAsModerator: this.i18n('New abuse'), 34 abuseAsModerator: $localize`New abuse`,
37 videoAutoBlacklistAsModerator: this.i18n('Video blocked automatically waiting review'), 35 videoAutoBlacklistAsModerator: $localize`Video blocked automatically waiting review`,
38 blacklistOnMyVideo: this.i18n('One of your video is blocked/unblocked'), 36 blacklistOnMyVideo: $localize`One of your video is blocked/unblocked`,
39 myVideoPublished: this.i18n('Video published (after transcoding/scheduled update)'), 37 myVideoPublished: $localize`Video published (after transcoding/scheduled update)`,
40 myVideoImportFinished: this.i18n('Video import finished'), 38 myVideoImportFinished: $localize`Video import finished`,
41 newUserRegistration: this.i18n('A new user registered on your instance'), 39 newUserRegistration: $localize`A new user registered on your instance`,
42 newFollow: this.i18n('You or your channel(s) has a new follower'), 40 newFollow: $localize`You or your channel(s) has a new follower`,
43 commentMention: this.i18n('Someone mentioned you in video comments'), 41 commentMention: $localize`Someone mentioned you in video comments`,
44 newInstanceFollower: this.i18n('Your instance has a new follower'), 42 newInstanceFollower: $localize`Your instance has a new follower`,
45 autoInstanceFollowing: this.i18n('Your instance automatically followed another instance'), 43 autoInstanceFollowing: $localize`Your instance automatically followed another instance`,
46 abuseNewMessage: this.i18n('An abuse report received a new message'), 44 abuseNewMessage: $localize`An abuse report received a new message`,
47 abuseStateChange: this.i18n('One of your abuse reports has been accepted or rejected by moderators') 45 abuseStateChange: $localize`One of your abuse reports has been accepted or rejected by moderators`
48 } 46 }
49 this.notificationSettingKeys = Object.keys(this.labelNotifications) as (keyof UserNotificationSetting)[] 47 this.notificationSettingKeys = Object.keys(this.labelNotifications) as (keyof UserNotificationSetting)[]
50 48
@@ -91,7 +89,7 @@ export class MyAccountNotificationPreferencesComponent implements OnInit {
91 this.userNotificationService.updateNotificationSettings(this.user, this.user.notificationSettings) 89 this.userNotificationService.updateNotificationSettings(this.user, this.user.notificationSettings)
92 .subscribe( 90 .subscribe(
93 () => { 91 () => {
94 this.notifier.success(this.i18n('Preferences saved'), undefined, 2000) 92 this.notifier.success($localize`Preferences saved`, undefined, 2000)
95 }, 93 },
96 94
97 err => this.notifier.error(err.message) 95 err => this.notifier.error(err.message)
diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
index b0d8494e7..ed0984bf7 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
@@ -2,7 +2,6 @@ import { Subject } from 'rxjs'
2import { Component, Input, OnInit } from '@angular/core' 2import { Component, Input, OnInit } from '@angular/core'
3import { Notifier, User, UserService } from '@app/core' 3import { Notifier, User, UserService } from '@app/core'
4import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 4import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
5import { I18n } from '@ngx-translate/i18n-polyfill'
6 5
7@Component({ 6@Component({
8 selector: 'my-account-profile', 7 selector: 'my-account-profile',
@@ -19,9 +18,8 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
19 protected formValidatorService: FormValidatorService, 18 protected formValidatorService: FormValidatorService,
20 private userValidatorsService: UserValidatorsService, 19 private userValidatorsService: UserValidatorsService,
21 private notifier: Notifier, 20 private notifier: Notifier,
22 private userService: UserService, 21 private userService: UserService
23 private i18n: I18n 22 ) {
24 ) {
25 super() 23 super()
26 } 24 }
27 25
@@ -50,7 +48,7 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
50 this.user.account.displayName = displayName 48 this.user.account.displayName = displayName
51 this.user.account.description = description 49 this.user.account.description = description
52 50
53 this.notifier.success(this.i18n('Profile updated.')) 51 this.notifier.success($localize`Profile updated.`)
54 }, 52 },
55 53
56 err => this.error = err.message 54 err => this.error = err.message
diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
index a3a8ff1f1..7ea4610d4 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
@@ -1,7 +1,6 @@
1import { ViewportScroller } from '@angular/common' 1import { ViewportScroller } from '@angular/common'
2import { AfterViewChecked, Component, OnInit } from '@angular/core' 2import { AfterViewChecked, Component, OnInit } from '@angular/core'
3import { AuthService, Notifier, User, UserService } from '@app/core' 3import { AuthService, Notifier, User, UserService } from '@app/core'
4import { I18n } from '@ngx-translate/i18n-polyfill'
5 4
6@Component({ 5@Component({
7 selector: 'my-account-settings', 6 selector: 'my-account-settings',
@@ -17,9 +16,8 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
17 private viewportScroller: ViewportScroller, 16 private viewportScroller: ViewportScroller,
18 private userService: UserService, 17 private userService: UserService,
19 private authService: AuthService, 18 private authService: AuthService,
20 private notifier: Notifier, 19 private notifier: Notifier
21 private i18n: I18n 20 ) {}
22 ) {}
23 21
24 get userInformationLoaded () { 22 get userInformationLoaded () {
25 return this.authService.userInformationLoaded 23 return this.authService.userInformationLoaded
@@ -41,7 +39,7 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
41 this.userService.changeAvatar(formData) 39 this.userService.changeAvatar(formData)
42 .subscribe( 40 .subscribe(
43 data => { 41 data => {
44 this.notifier.success(this.i18n('Avatar changed.')) 42 this.notifier.success($localize`Avatar changed.`)
45 43
46 this.user.updateAccountAvatar(data.avatar) 44 this.user.updateAccountAvatar(data.avatar)
47 }, 45 },