aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit/shared
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/+videos/+video-edit/shared
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/+videos/+video-edit/shared')
-rw-r--r--client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts102
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts10
2 files changed, 53 insertions, 59 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts b/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts
index b05852ff8..2acbace48 100644
--- a/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts
+++ b/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts
@@ -1,76 +1,75 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
3 2
4@Injectable() 3@Injectable()
5export class I18nPrimengCalendarService { 4export class I18nPrimengCalendarService {
6 private readonly calendarLocale: any = {} 5 private readonly calendarLocale: any = {}
7 6
8 constructor (private i18n: I18n) { 7 constructor () {
9 this.calendarLocale = { 8 this.calendarLocale = {
10 firstDayOfWeek: 0, 9 firstDayOfWeek: 0,
11 dayNames: [ 10 dayNames: [
12 this.i18n('Sunday'), 11 $localize`Sunday`,
13 this.i18n('Monday'), 12 $localize`Monday`,
14 this.i18n('Tuesday'), 13 $localize`Tuesday`,
15 this.i18n('Wednesday'), 14 $localize`Wednesday`,
16 this.i18n('Thursday'), 15 $localize`Thursday`,
17 this.i18n('Friday'), 16 $localize`Friday`,
18 this.i18n('Saturday') 17 $localize`Saturday`
19 ], 18 ],
20 19
21 dayNamesShort: [ 20 dayNamesShort: [
22 this.i18n({ value: 'Sun', description: 'Day name short' }), 21 $localize`:Day name short:Sun`,
23 this.i18n({ value: 'Mon', description: 'Day name short' }), 22 $localize`:Day name short:Mon`,
24 this.i18n({ value: 'Tue', description: 'Day name short' }), 23 $localize`:Day name short:Tue`,
25 this.i18n({ value: 'Wed', description: 'Day name short' }), 24 $localize`:Day name short:Wed`,
26 this.i18n({ value: 'Thu', description: 'Day name short' }), 25 $localize`:Day name short:Thu`,
27 this.i18n({ value: 'Fri', description: 'Day name short' }), 26 $localize`:Day name short:Fri`,
28 this.i18n({ value: 'Sat', description: 'Day name short' }) 27 $localize`:Day name short:Sat`
29 ], 28 ],
30 29
31 dayNamesMin: [ 30 dayNamesMin: [
32 this.i18n({ value: 'Su', description: 'Day name min' }), 31 $localize`:Day name min:Su`,
33 this.i18n({ value: 'Mo', description: 'Day name min' }), 32 $localize`:Day name min:Mo`,
34 this.i18n({ value: 'Tu', description: 'Day name min' }), 33 $localize`:Day name min:Tu`,
35 this.i18n({ value: 'We', description: 'Day name min' }), 34 $localize`:Day name min:We`,
36 this.i18n({ value: 'Th', description: 'Day name min' }), 35 $localize`:Day name min:Th`,
37 this.i18n({ value: 'Fr', description: 'Day name min' }), 36 $localize`:Day name min:Fr`,
38 this.i18n({ value: 'Sa', description: 'Day name min' }) 37 $localize`:Day name min:Sa`
39 ], 38 ],
40 39
41 monthNames: [ 40 monthNames: [
42 this.i18n('January'), 41 $localize`January`,
43 this.i18n('February'), 42 $localize`February`,
44 this.i18n('March'), 43 $localize`March`,
45 this.i18n('April'), 44 $localize`April`,
46 this.i18n('May'), 45 $localize`May`,
47 this.i18n('June'), 46 $localize`June`,
48 this.i18n('July'), 47 $localize`July`,
49 this.i18n('August'), 48 $localize`August`,
50 this.i18n('September'), 49 $localize`September`,
51 this.i18n('October'), 50 $localize`October`,
52 this.i18n('November'), 51 $localize`November`,
53 this.i18n('December') 52 $localize`December`
54 ], 53 ],
55 54
56 monthNamesShort: [ 55 monthNamesShort: [
57 this.i18n({ value: 'Jan', description: 'Month name short' }), 56 $localize`:Month name short:Jan`,
58 this.i18n({ value: 'Feb', description: 'Month name short' }), 57 $localize`:Month name short:Feb`,
59 this.i18n({ value: 'Mar', description: 'Month name short' }), 58 $localize`:Month name short:Mar`,
60 this.i18n({ value: 'Apr', description: 'Month name short' }), 59 $localize`:Month name short:Apr`,
61 this.i18n({ value: 'May', description: 'Month name short' }), 60 $localize`:Month name short:May`,
62 this.i18n({ value: 'Jun', description: 'Month name short' }), 61 $localize`:Month name short:Jun`,
63 this.i18n({ value: 'Jul', description: 'Month name short' }), 62 $localize`:Month name short:Jul`,
64 this.i18n({ value: 'Aug', description: 'Month name short' }), 63 $localize`:Month name short:Aug`,
65 this.i18n({ value: 'Sep', description: 'Month name short' }), 64 $localize`:Month name short:Sep`,
66 this.i18n({ value: 'Oct', description: 'Month name short' }), 65 $localize`:Month name short:Oct`,
67 this.i18n({ value: 'Nov', description: 'Month name short' }), 66 $localize`:Month name short:Nov`,
68 this.i18n({ value: 'Dec', description: 'Month name short' }) 67 $localize`:Month name short:Dec`
69 ], 68 ],
70 69
71 today: this.i18n('Today'), 70 today: $localize`Today`,
72 71
73 clear: this.i18n('Clear') 72 clear: $localize`Clear`
74 } 73 }
75 } 74 }
76 75
@@ -86,9 +85,6 @@ export class I18nPrimengCalendarService {
86 } 85 }
87 86
88 getDateFormat () { 87 getDateFormat () {
89 return this.i18n({ 88 return $localize`:Date format in this locale.:yy-mm-dd`
90 value: 'yy-mm-dd ',
91 description: 'Date format in this locale.'
92 })
93 } 89 }
94} 90}
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
index ba3b7c96a..050b6d931 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
@@ -7,7 +7,6 @@ import { removeElementFromArray } from '@app/helpers'
7import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem, VideoValidatorsService } from '@app/shared/shared-forms' 7import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem, VideoValidatorsService } from '@app/shared/shared-forms'
8import { InstanceService } from '@app/shared/shared-instance' 8import { InstanceService } from '@app/shared/shared-instance'
9import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' 9import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
10import { I18n } from '@ngx-translate/i18n-polyfill'
11import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' 10import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
12import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' 11import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
13import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' 12import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
@@ -63,7 +62,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
63 private serverService: ServerService, 62 private serverService: ServerService,
64 private instanceService: InstanceService, 63 private instanceService: InstanceService,
65 private i18nPrimengCalendarService: I18nPrimengCalendarService, 64 private i18nPrimengCalendarService: I18nPrimengCalendarService,
66 private i18n: I18n,
67 private ngZone: NgZone 65 private ngZone: NgZone
68 ) { 66 ) {
69 this.calendarLocale = this.i18nPrimengCalendarService.getCalendarLocale() 67 this.calendarLocale = this.i18nPrimengCalendarService.getCalendarLocale()
@@ -137,8 +135,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
137 .subscribe(res => { 135 .subscribe(res => {
138 this.videoLanguages = res.languages 136 this.videoLanguages = res.languages
139 .map(l => res.about.instance.languages.includes(l.id) 137 .map(l => res.about.instance.languages.includes(l.id)
140 ? { ...l, group: this.i18n('Instance languages'), groupOrder: 0 } 138 ? { ...l, group: $localize`Instance languages`, groupOrder: 0 }
141 : { ...l, group: this.i18n('All languages'), groupOrder: 1 }) 139 : { ...l, group: $localize`All languages`, groupOrder: 1 })
142 .sort((a, b) => a.groupOrder - b.groupOrder) 140 .sort((a, b) => a.groupOrder - b.groupOrder)
143 }) 141 })
144 142
@@ -148,8 +146,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
148 if (this.schedulePublicationPossible) { 146 if (this.schedulePublicationPossible) {
149 this.videoPrivacies.push({ 147 this.videoPrivacies.push({
150 id: this.SPECIAL_SCHEDULED_PRIVACY, 148 id: this.SPECIAL_SCHEDULED_PRIVACY,
151 label: this.i18n('Scheduled'), 149 label: $localize`Scheduled`,
152 description: this.i18n('Hide the video until a specific date') 150 description: $localize`Hide the video until a specific date`
153 }) 151 })
154 } 152 }
155 }) 153 })