From a2d1b154a311813b61763256fdfc12aa2fc5ce39 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Thu, 23 Jun 2022 01:22:22 -0400 Subject: [PATCH] Fixed broken translations for snackbars --- .../recent-videos/recent-videos.component.ts | 11 +- .../share-media-dialog.component.ts | 14 +- .../subscribe-dialog.component.ts | 13 +- .../update-progress-dialog.component.ts | 12 +- src/app/main/main.component.ts | 4 +- src/app/player/player.component.ts | 12 +- src/app/settings/settings.component.ts | 3 +- src/assets/i18n/messages.en.xlf | 159 ++++++++++++++---- 8 files changed, 151 insertions(+), 77 deletions(-) diff --git a/src/app/components/recent-videos/recent-videos.component.ts b/src/app/components/recent-videos/recent-videos.component.ts index e6eb7d0..0c2f9f8 100644 --- a/src/app/components/recent-videos/recent-videos.component.ts +++ b/src/app/components/recent-videos/recent-videos.component.ts @@ -276,13 +276,13 @@ export class RecentVideosComponent implements OnInit { deleteNormalFile(file: DatabaseFile, blacklistMode = false): void { this.postsService.deleteFile(file.uid, blacklistMode).subscribe(result => { if (result) { - this.postsService.openSnackBar($localize`Delete success!', 'OK.`); + this.postsService.openSnackBar($localize`Delete success!`, $localize`OK.`); this.removeFileCard(file); } else { - this.postsService.openSnackBar($localize`Delete failed!', 'OK.`); + this.postsService.openSnackBar($localize`Delete failed!`, $localize`OK.`); } }, () => { - this.postsService.openSnackBar($localize`Delete failed!', 'OK.`); + this.postsService.openSnackBar($localize`Delete failed!`, $localize`OK.`); }); } @@ -297,7 +297,7 @@ export class RecentVideosComponent implements OnInit { deleteAndRedownload(file: DatabaseFile): void { const sub = this.postsService.getSubscriptionByID(file.sub_id); this.postsService.deleteSubscriptionFile(sub, file.id, false, file.uid).subscribe(() => { - this.postsService.openSnackBar(`Successfully deleted file: '${file.id}'`); + this.postsService.openSnackBar($localize`Successfully deleted file: ` + file.id); this.removeFileCard(file); }); } @@ -305,7 +305,7 @@ export class RecentVideosComponent implements OnInit { deleteForever(file: DatabaseFile): void { const sub = this.postsService.getSubscriptionByID(file.sub_id); this.postsService.deleteSubscriptionFile(sub, file.id, true, file.uid).subscribe(() => { - this.postsService.openSnackBar(`Successfully deleted file: '${file.id}'`); + this.postsService.openSnackBar($localize`Successfully deleted file: ` + file.id); this.removeFileCard(file); }); } @@ -316,6 +316,7 @@ export class RecentVideosComponent implements OnInit { this.getAllFiles(true); } + // TODO: Add translation support for these snackbars addFileToPlaylist(info_obj) { const file = info_obj['file']; const playlist_id = info_obj['playlist_id']; diff --git a/src/app/dialogs/share-media-dialog/share-media-dialog.component.ts b/src/app/dialogs/share-media-dialog/share-media-dialog.component.ts index 332a461..e4f2912 100644 --- a/src/app/dialogs/share-media-dialog/share-media-dialog.component.ts +++ b/src/app/dialogs/share-media-dialog/share-media-dialog.component.ts @@ -58,31 +58,31 @@ export class ShareMediaDialogComponent implements OnInit { } copiedToClipboard() { - this.openSnackBar('Copied to clipboard!'); + this.postsService.openSnackBar($localize`Copied to clipboard!`); } sharingChanged(event) { if (event.checked) { this.postsService.enableSharing(this.uid, this.is_playlist).subscribe(res => { if (res['success']) { - this.openSnackBar('Sharing enabled.'); + this.postsService.openSnackBar($localize`Sharing enabled.`); this.sharing_enabled = true; } else { - this.openSnackBar('Failed to enable sharing.'); + this.postsService.openSnackBar($localize`Failed to enable sharing.`); } }, err => { - this.openSnackBar('Failed to enable sharing - server error.'); + this.postsService.openSnackBar($localize`Failed to enable sharing - server error.`); }); } else { this.postsService.disableSharing(this.uid, this.is_playlist).subscribe(res => { if (res['success']) { - this.openSnackBar('Sharing disabled.'); + this.postsService.openSnackBar($localize`Sharing disabled.`); this.sharing_enabled = false; } else { - this.openSnackBar('Failed to disable sharing.'); + this.postsService.openSnackBar($localize`Failed to disable sharing.`); } }, err => { - this.openSnackBar('Failed to disable sharing - server error.'); + this.postsService.openSnackBar($localize`Failed to disable sharing - server error.`); }); } } diff --git a/src/app/dialogs/subscribe-dialog/subscribe-dialog.component.ts b/src/app/dialogs/subscribe-dialog/subscribe-dialog.component.ts index 916b5f9..3e7640a 100644 --- a/src/app/dialogs/subscribe-dialog/subscribe-dialog.component.ts +++ b/src/app/dialogs/subscribe-dialog/subscribe-dialog.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit } from '@angular/core'; import { MatDialogRef, MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; import { PostsService } from 'app/posts.services'; import { ArgModifierDialogComponent } from '../arg-modifier-dialog/arg-modifier-dialog.component'; @@ -70,7 +69,6 @@ export class SubscribeDialogComponent implements OnInit { ]; constructor(private postsService: PostsService, - private snackBar: MatSnackBar, private dialog: MatDialog, public dialogRef: MatDialogRef) { } @@ -81,7 +79,7 @@ export class SubscribeDialogComponent implements OnInit { if (this.url && this.url !== '') { // timerange must be specified if download_all is false if (!this.download_all && !this.timerange_amount) { - this.openSnackBar('You must specify an amount of time'); + this.postsService.openSnackBar($localize`You must specify an amount of time`); return; } this.subscribing = true; @@ -97,7 +95,7 @@ export class SubscribeDialogComponent implements OnInit { this.dialogRef.close(res['new_sub']); } else { if (res['error']) { - this.openSnackBar('ERROR: ' + res['error']); + this.postsService.openSnackBar($localize`ERROR: ` + res['error']); } this.dialogRef.close(); } @@ -118,11 +116,4 @@ export class SubscribeDialogComponent implements OnInit { } }); } - - public openSnackBar(message: string, action = '') { - this.snackBar.open(message, action, { - duration: 2000, - }); - } - } diff --git a/src/app/dialogs/update-progress-dialog/update-progress-dialog.component.ts b/src/app/dialogs/update-progress-dialog/update-progress-dialog.component.ts index 4862839..888aa85 100644 --- a/src/app/dialogs/update-progress-dialog/update-progress-dialog.component.ts +++ b/src/app/dialogs/update-progress-dialog/update-progress-dialog.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit } from '@angular/core'; import { PostsService } from 'app/posts.services'; -import { MatSnackBar } from '@angular/material/snack-bar'; import { UpdaterStatus } from '../../../api-types'; @Component({ @@ -14,7 +13,7 @@ export class UpdateProgressDialogComponent implements OnInit { updateInterval = 250; errored = false; - constructor(private postsService: PostsService, private snackBar: MatSnackBar) { } + constructor(private postsService: PostsService) { } ngOnInit(): void { this.getUpdateProgress(); @@ -28,16 +27,9 @@ export class UpdateProgressDialogComponent implements OnInit { if (res) { this.updateStatus = res; if (this.updateStatus && this.updateStatus['error']) { - this.openSnackBar('Update failed. Check logs for more details.'); + this.postsService.openSnackBar($localize`Update failed. Check logs for more details.`); } } }); } - - public openSnackBar(message: string, action: string = '') { - this.snackBar.open(message, action, { - duration: 2000, - }); - } - } diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 4bfee05..26078ff 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -384,7 +384,7 @@ export class MainComponent implements OnInit { }, () => { // can't access server this.downloadingfile = false; this.current_download = null; - this.postsService.openSnackBar($localize`Download failed!', 'OK.`); + this.postsService.openSnackBar($localize`Download failed!`, 'OK.'); }); if (!this.autoplay && urls.length === 1) { @@ -771,7 +771,7 @@ export class MainComponent implements OnInit { } else if (this.current_download['finished'] && this.current_download['error']) { this.downloadingfile = false; this.current_download = null; - this.postsService.openSnackBar($localize`Download failed!', 'OK.`); + this.postsService.openSnackBar($localize`Download failed!`, 'OK.'); } } else { // console.log('failed to get new download'); diff --git a/src/app/player/player.component.ts b/src/app/player/player.component.ts index 4dbaa8c..053e931 100644 --- a/src/app/player/player.component.ts +++ b/src/app/player/player.component.ts @@ -3,7 +3,6 @@ import { VgApiService } from '@videogular/ngx-videogular/core'; import { PostsService } from 'app/posts.services'; import { ActivatedRoute, Router } from '@angular/router'; import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; import { ShareMediaDialogComponent } from '../dialogs/share-media-dialog/share-media-dialog.component'; import { FileType } from '../../api-types'; @@ -109,7 +108,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy { } constructor(public postsService: PostsService, private route: ActivatedRoute, private dialog: MatDialog, private router: Router, - public snackBar: MatSnackBar, private cdr: ChangeDetectorRef) { + private cdr: ChangeDetectorRef) { } processConfig(): void { @@ -147,7 +146,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy { this.postsService.getFile(this.uid, this.uuid).subscribe(res => { this.db_file = res['file']; if (!this.db_file) { - this.postsService.openSnackBar($localize`Failed to get file information from the server.', 'Dismiss`); + this.postsService.openSnackBar($localize`Failed to get file information from the server.`, 'Dismiss'); return; } this.postsService.incrementViewCount(this.db_file['uid'], null, this.uuid).subscribe(() => undefined, err => { @@ -169,6 +168,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy { this.uids = this.subscription.videos.map(video => video['uid']); this.parseFileNames(); }, () => { + // TODO: Make translatable this.postsService.openSnackBar(`Failed to find subscription ${this.sub_id}`, 'Dismiss'); }); } @@ -183,10 +183,10 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy { this.show_player = true; this.parseFileNames(); } else { - this.postsService.openSnackBar($localize`Failed to load playlist!', '`); + this.postsService.openSnackBar($localize`Failed to load playlist!`); } }, () => { - this.postsService.openSnackBar($localize`Failed to load playlist!', '`); + this.postsService.openSnackBar($localize`Failed to load playlist!`); }); } @@ -351,7 +351,7 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy { width: '60vw' }); - dialogRef.afterClosed().subscribe(res => { + dialogRef.afterClosed().subscribe(() => { if (!this.playlist_id) { this.getFile(); } else { diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index f46709f..1771e66 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -176,6 +176,7 @@ export class SettingsComponent implements OnInit { if (confirmed) { this.postsService.deleteCategory(category['uid']).subscribe(res => { if (res['success']) { + // TODO: Make translatable this.postsService.openSnackBar(`Successfully deleted ${category['name']}!`); this.postsService.reloadCategories(); } @@ -233,7 +234,7 @@ export class SettingsComponent implements OnInit { window['external']['AddFavorite'](url, title); } else if (window['chrome']) { // Google Chrome - this.postsService.openSnackBar($localize`Chrome users must drag the \'Alternate URL\' link to your bookmarks.`); + this.postsService.openSnackBar($localize`Chrome users must drag the 'Alternate URL' link to your bookmarks.`); } else if (window['sidebar']) { // Firefox window['sidebar'].addPanel(title, url, ''); diff --git a/src/assets/i18n/messages.en.xlf b/src/assets/i18n/messages.en.xlf index 98e3fcb..5c40019 100644 --- a/src/assets/i18n/messages.en.xlf +++ b/src/assets/i18n/messages.en.xlf @@ -448,6 +448,10 @@ src/app/components/downloads/downloads.component.ts 270 + + src/app/dialogs/share-media-dialog/share-media-dialog.component.ts + 61 + User name @@ -861,15 +865,19 @@ Audio only - - Delete success!', 'OK. + + Delete success! src/app/components/recent-videos/recent-videos.component.ts 279 - - Delete failed!', 'OK. + + OK. + + src/app/components/recent-videos/recent-videos.component.ts + 279 + src/app/components/recent-videos/recent-videos.component.ts 282 @@ -879,6 +887,28 @@ 285 + + Delete failed! + + src/app/components/recent-videos/recent-videos.component.ts + 282 + + + src/app/components/recent-videos/recent-videos.component.ts + 285 + + + + Successfully deleted file: + + src/app/components/recent-videos/recent-videos.component.ts + 300 + + + src/app/components/recent-videos/recent-videos.component.ts + 308 + + See more. @@ -1191,12 +1221,16 @@ Delete and redownload subscription video button - - Delete forever + + Delete and blacklist src/app/components/unified-file-card/unified-file-card.component.html 37 + + src/app/components/unified-file-card/unified-file-card.component.html + 40 + Delete forever subscription video button @@ -1211,14 +1245,6 @@ Delete video button - - Delete and blacklist - - src/app/components/unified-file-card/unified-file-card.component.html - 40 - - Delete and blacklist video button - Edit @@ -1817,6 +1843,48 @@ Copy to clipboard button + + Sharing enabled. + + src/app/dialogs/share-media-dialog/share-media-dialog.component.ts + 68 + + + + Failed to enable sharing. + + src/app/dialogs/share-media-dialog/share-media-dialog.component.ts + 71 + + + + Failed to enable sharing - server error. + + src/app/dialogs/share-media-dialog/share-media-dialog.component.ts + 74 + + + + Sharing disabled. + + src/app/dialogs/share-media-dialog/share-media-dialog.component.ts + 79 + + + + Failed to disable sharing. + + src/app/dialogs/share-media-dialog/share-media-dialog.component.ts + 82 + + + + Failed to disable sharing - server error. + + src/app/dialogs/share-media-dialog/share-media-dialog.component.ts + 85 + + Subscribe to playlist or channel @@ -1865,6 +1933,20 @@ Subscribe button + + You must specify an amount of time + + src/app/dialogs/subscribe-dialog/subscribe-dialog.component.ts + 82 + + + + ERROR: + + src/app/dialogs/subscribe-dialog/subscribe-dialog.component.ts + 98 + + Type: @@ -1921,6 +2003,13 @@ Update progress dialog title + + Update failed. Check logs for more details. + + src/app/dialogs/update-progress-dialog/update-progress-dialog.component.ts + 30 + + Update task schedule @@ -2233,8 +2322,8 @@ Crop to placeholder - - Download failed!', 'OK. + + Download failed! src/app/main/main.component.ts 387 @@ -2259,22 +2348,22 @@ View count label - - Failed to get file information from the server.', 'Dismiss + + Failed to get file information from the server. src/app/player/player.component.ts 150 - - Failed to load playlist!', ' + + Failed to load playlist! src/app/player/player.component.ts - 186 + 187 src/app/player/player.component.ts - 189 + 190 @@ -3079,88 +3168,88 @@ Language successfully changed! Reload to update the page. src/app/settings/settings.component.ts - 208 + 209 Chrome users must drag the 'Alternate URL' link to your bookmarks. src/app/settings/settings.component.ts - 236 + 237 Successfully killed all downloads! src/app/settings/settings.component.ts - 291 + 292 Failed to kill all downloads! Check logs for details. src/app/settings/settings.component.ts - 294 + 295 src/app/settings/settings.component.ts - 298 + 299 Restarting! src/app/settings/settings.component.ts - 306 + 307 Failed to restart the server. src/app/settings/settings.component.ts - 308 + 309 Successfully transfered DB! Reloading info... src/app/settings/settings.component.ts - 339 + 340 Failed to transfer DB -- transfer was aborted. Error: src/app/settings/settings.component.ts - 342 + 343 Failed to transfer DB -- API call failed. See browser logs for details. src/app/settings/settings.component.ts - 346 + 347 Connection successful! src/app/settings/settings.component.ts - 356 + 357 Connection failed! Error: src/app/settings/settings.component.ts - 358 + 359 Connection failed! Error: Server error. See logs for more info. src/app/settings/settings.component.ts - 362 + 363