aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+search
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/+search
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/+search')
-rw-r--r--client/src/app/+search/search-filters.component.ts28
-rw-r--r--client/src/app/+search/search.component.ts8
2 files changed, 15 insertions, 21 deletions
diff --git a/client/src/app/+search/search-filters.component.ts b/client/src/app/+search/search-filters.component.ts
index 13ad61647..a2af9a942 100644
--- a/client/src/app/+search/search-filters.component.ts
+++ b/client/src/app/+search/search-filters.component.ts
@@ -1,8 +1,6 @@
1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
2import { ServerService } from '@app/core' 2import { ServerService } from '@app/core'
3import { VideoValidatorsService } from '@app/shared/shared-forms'
4import { AdvancedSearch } from '@app/shared/shared-search' 3import { AdvancedSearch } from '@app/shared/shared-search'
5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { ServerConfig, VideoConstant } from '@shared/models' 4import { ServerConfig, VideoConstant } from '@shared/models'
7 5
8@Component({ 6@Component({
@@ -32,64 +30,62 @@ export class SearchFiltersComponent implements OnInit {
32 private serverConfig: ServerConfig 30 private serverConfig: ServerConfig
33 31
34 constructor ( 32 constructor (
35 private i18n: I18n,
36 private videoValidatorsService: VideoValidatorsService,
37 private serverService: ServerService 33 private serverService: ServerService
38 ) { 34 ) {
39 this.publishedDateRanges = [ 35 this.publishedDateRanges = [
40 { 36 {
41 id: 'any_published_date', 37 id: 'any_published_date',
42 label: this.i18n('Any') 38 label: $localize`Any`
43 }, 39 },
44 { 40 {
45 id: 'today', 41 id: 'today',
46 label: this.i18n('Today') 42 label: $localize`Today`
47 }, 43 },
48 { 44 {
49 id: 'last_7days', 45 id: 'last_7days',
50 label: this.i18n('Last 7 days') 46 label: $localize`Last 7 days`
51 }, 47 },
52 { 48 {
53 id: 'last_30days', 49 id: 'last_30days',
54 label: this.i18n('Last 30 days') 50 label: $localize`Last 30 days`
55 }, 51 },
56 { 52 {
57 id: 'last_365days', 53 id: 'last_365days',
58 label: this.i18n('Last 365 days') 54 label: $localize`Last 365 days`
59 } 55 }
60 ] 56 ]
61 57
62 this.durationRanges = [ 58 this.durationRanges = [
63 { 59 {
64 id: 'any_duration', 60 id: 'any_duration',
65 label: this.i18n('Any') 61 label: $localize`Any`
66 }, 62 },
67 { 63 {
68 id: 'short', 64 id: 'short',
69 label: this.i18n('Short (< 4 min)') 65 label: $localize`Short (< 4 min)`
70 }, 66 },
71 { 67 {
72 id: 'medium', 68 id: 'medium',
73 label: this.i18n('Medium (4-10 min)') 69 label: $localize`Medium (4-10 min)`
74 }, 70 },
75 { 71 {
76 id: 'long', 72 id: 'long',
77 label: this.i18n('Long (> 10 min)') 73 label: $localize`Long (> 10 min)`
78 } 74 }
79 ] 75 ]
80 76
81 this.sorts = [ 77 this.sorts = [
82 { 78 {
83 id: '-match', 79 id: '-match',
84 label: this.i18n('Relevance') 80 label: $localize`Relevance`
85 }, 81 },
86 { 82 {
87 id: '-publishedAt', 83 id: '-publishedAt',
88 label: this.i18n('Publish date') 84 label: $localize`Publish date`
89 }, 85 },
90 { 86 {
91 id: '-views', 87 id: '-views',
92 label: this.i18n('Views') 88 label: $localize`Views`
93 } 89 }
94 ] 90 ]
95 } 91 }
diff --git a/client/src/app/+search/search.component.ts b/client/src/app/+search/search.component.ts
index 70116fab3..2be952e16 100644
--- a/client/src/app/+search/search.component.ts
+++ b/client/src/app/+search/search.component.ts
@@ -7,7 +7,6 @@ import { Video, VideoChannel } from '@app/shared/shared-main'
7import { AdvancedSearch, SearchService } from '@app/shared/shared-search' 7import { AdvancedSearch, SearchService } from '@app/shared/shared-search'
8import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature' 8import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature'
9import { MetaService } from '@ngx-meta/core' 9import { MetaService } from '@ngx-meta/core'
10import { I18n } from '@ngx-translate/i18n-polyfill'
11import { SearchTargetType, ServerConfig } from '@shared/models' 10import { SearchTargetType, ServerConfig } from '@shared/models'
12 11
13@Component({ 12@Component({
@@ -52,7 +51,6 @@ export class SearchComponent implements OnInit, OnDestroy {
52 private lastSearchTarget: SearchTargetType 51 private lastSearchTarget: SearchTargetType
53 52
54 constructor ( 53 constructor (
55 private i18n: I18n,
56 private route: ActivatedRoute, 54 private route: ActivatedRoute,
57 private router: Router, 55 private router: Router,
58 private metaService: MetaService, 56 private metaService: MetaService,
@@ -170,8 +168,8 @@ export class SearchComponent implements OnInit, OnDestroy {
170 } 168 }
171 169
172 this.notifier.error( 170 this.notifier.error(
173 this.i18n('Search index is unavailable. Retrying with instance results instead.'), 171 $localize`Search index is unavailable. Retrying with instance results instead.`,
174 this.i18n('Search error') 172 $localize`Search error`
175 ) 173 )
176 this.advancedSearch.searchTarget = 'local' 174 this.advancedSearch.searchTarget = 'local'
177 this.search() 175 this.search()
@@ -229,7 +227,7 @@ export class SearchComponent implements OnInit, OnDestroy {
229 227
230 private updateTitle () { 228 private updateTitle () {
231 const suffix = this.currentSearch ? ' ' + this.currentSearch : '' 229 const suffix = this.currentSearch ? ' ' + this.currentSearch : ''
232 this.metaService.setTitle(this.i18n('Search') + suffix) 230 this.metaService.setTitle($localize`Search` + suffix)
233 } 231 }
234 232
235 private updateUrlFromAdvancedSearch () { 233 private updateUrlFromAdvancedSearch () {