aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-user-settings/user-video-settings.component.ts
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/shared/shared-user-settings/user-video-settings.component.ts
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/shared/shared-user-settings/user-video-settings.component.ts')
-rw-r--r--client/src/app/shared/shared-user-settings/user-video-settings.component.ts24
1 files changed, 7 insertions, 17 deletions
diff --git a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts
index eb340e24d..ab77f6f9c 100644
--- a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts
+++ b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts
@@ -4,7 +4,6 @@ import { first } from 'rxjs/operators'
4import { Component, Input, OnDestroy, OnInit } from '@angular/core' 4import { Component, Input, OnDestroy, OnInit } from '@angular/core'
5import { AuthService, Notifier, ServerService, User, UserService } from '@app/core' 5import { AuthService, Notifier, ServerService, User, UserService } from '@app/core'
6import { FormReactive, FormValidatorService, ItemSelectCheckboxValue, SelectOptionsItem } from '@app/shared/shared-forms' 6import { FormReactive, FormValidatorService, ItemSelectCheckboxValue, SelectOptionsItem } from '@app/shared/shared-forms'
7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { UserUpdateMe } from '@shared/models' 7import { UserUpdateMe } from '@shared/models'
9import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' 8import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
10 9
@@ -30,14 +29,13 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit,
30 private authService: AuthService, 29 private authService: AuthService,
31 private notifier: Notifier, 30 private notifier: Notifier,
32 private userService: UserService, 31 private userService: UserService,
33 private serverService: ServerService, 32 private serverService: ServerService
34 private i18n: I18n
35 ) { 33 ) {
36 super() 34 super()
37 } 35 }
38 36
39 ngOnInit () { 37 ngOnInit () {
40 this.allLanguagesGroup = this.i18n('All languages') 38 this.allLanguagesGroup = $localize`All languages`
41 39
42 let oldForm: any 40 let oldForm: any
43 41
@@ -56,7 +54,7 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit,
56 ]).subscribe(([ languages, config ]) => { 54 ]).subscribe(([ languages, config ]) => {
57 const group = this.allLanguagesGroup 55 const group = this.allLanguagesGroup
58 56
59 this.languageItems = [ { label: this.i18n('Unknown language'), id: '_unknown', group } ] 57 this.languageItems = [ { label: $localize`Unknown language`, id: '_unknown', group } ]
60 this.languageItems = this.languageItems 58 this.languageItems = this.languageItems
61 .concat(languages.map(l => ({ label: l.label, id: l.id, group }))) 59 .concat(languages.map(l => ({ label: l.label, id: l.id, group })))
62 60
@@ -101,12 +99,12 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit,
101 99
102 if (Array.isArray(videoLanguages)) { 100 if (Array.isArray(videoLanguages)) {
103 if (videoLanguages.length > 20) { 101 if (videoLanguages.length > 20) {
104 this.notifier.error(this.i18n('Too many languages are enabled. Please enable them all or stay below 20 enabled languages.')) 102 this.notifier.error($localize`Too many languages are enabled. Please enable them all or stay below 20 enabled languages.`)
105 return 103 return
106 } 104 }
107 105
108 if (videoLanguages.length === 0) { 106 if (videoLanguages.length === 0) {
109 this.notifier.error(this.i18n('You need to enable at least 1 video language.')) 107 this.notifier.error($localize`You need to enable at least 1 video language.`)
110 return 108 return
111 } 109 }
112 110
@@ -133,22 +131,14 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit,
133 () => { 131 () => {
134 this.authService.refreshUserInformation() 132 this.authService.refreshUserInformation()
135 133
136 if (this.notifyOnUpdate) this.notifier.success(this.i18n('Video settings updated.')) 134 if (this.notifyOnUpdate) this.notifier.success($localize`Video settings updated.`)
137 }, 135 },
138 136
139 err => this.notifier.error(err.message) 137 err => this.notifier.error(err.message)
140 ) 138 )
141 } else { 139 } else {
142 this.userService.updateMyAnonymousProfile(details) 140 this.userService.updateMyAnonymousProfile(details)
143 if (this.notifyOnUpdate) this.notifier.success(this.i18n('Display/Video settings updated.')) 141 if (this.notifyOnUpdate) this.notifier.success($localize`Display/Video settings updated.`)
144 } 142 }
145 } 143 }
146
147 getDefaultVideoLanguageLabel () {
148 return this.i18n('No language')
149 }
150
151 getSelectedVideoLanguageLabel () {
152 return this.i18n('{{\'{0} languages selected')
153 }
154} 144}