Improved snackbar translations support

This commit is contained in:
Isaac Abadi
2022-06-20 16:25:55 -04:00
parent 4c6c15d3a3
commit cbdd1a6253
11 changed files with 60 additions and 57 deletions

View File

@@ -53,9 +53,9 @@ export class CustomPlaylistsComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => {
if (result) {
this.getAllPlaylists();
this.postsService.openSnackBar('Successfully created playlist!', '');
this.postsService.openSnackBar($localize`Successfully created playlist!', '`);
} else if (result === false) {
this.postsService.openSnackBar('ERROR: failed to create playlist!', '');
this.postsService.openSnackBar($localize`ERROR: failed to create playlist!', '`);
}
});
}
@@ -96,7 +96,7 @@ export class CustomPlaylistsComponent implements OnInit {
this.postsService.removePlaylist(playlistID).subscribe(res => {
if (res['success']) {
this.playlists.splice(index, 1);
this.postsService.openSnackBar('Playlist successfully removed.', '');
this.postsService.openSnackBar($localize`Playlist successfully removed.', '`);
}
this.getAllPlaylists();
});

View File

@@ -8,6 +8,7 @@ import { MatDialog } from '@angular/material/dialog';
import { ConfirmDialogComponent } from 'app/dialogs/confirm-dialog/confirm-dialog.component';
import { MatSort } from '@angular/material/sort';
import { Clipboard } from '@angular/cdk/clipboard';
import { Download } from 'api-types';
@Component({
selector: 'app-downloads',
@@ -68,7 +69,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
sort_downloads = (a, b) => {
sort_downloads = (a: Download, b: Download): number => {
const result = b.timestamp_start - a.timestamp_start;
return result;
}
@@ -166,7 +167,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
pauseDownload(download_uid: string): void {
this.postsService.pauseDownload(download_uid).subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to pause download! See server logs for more info.');
this.postsService.openSnackBar($localize`Failed to pause download! See server logs for more info.`);
}
});
}
@@ -174,7 +175,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
pauseAllDownloads(): void {
this.postsService.pauseAllDownloads().subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to pause all downloads! See server logs for more info.');
this.postsService.openSnackBar($localize`Failed to pause all downloads! See server logs for more info.`);
}
});
}
@@ -182,7 +183,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
resumeDownload(download_uid: string): void {
this.postsService.resumeDownload(download_uid).subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to resume download! See server logs for more info.');
this.postsService.openSnackBar($localize`Failed to resume download! See server logs for more info.`);
}
});
}
@@ -190,7 +191,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
resumeAllDownloads(): void {
this.postsService.resumeAllDownloads().subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to resume all downloads! See server logs for more info.');
this.postsService.openSnackBar($localize`Failed to resume all downloads! See server logs for more info.`);
}
});
}
@@ -198,7 +199,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
restartDownload(download_uid: string): void {
this.postsService.restartDownload(download_uid).subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to restart download! See server logs for more info.');
this.postsService.openSnackBar($localize`Failed to restart download! See server logs for more info.`);
}
});
}
@@ -206,7 +207,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
cancelDownload(download_uid: string): void {
this.postsService.cancelDownload(download_uid).subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to cancel download! See server logs for more info.');
this.postsService.openSnackBar($localize`Failed to cancel download! See server logs for more info.`);
}
});
}
@@ -214,12 +215,12 @@ export class DownloadsComponent implements OnInit, OnDestroy {
clearDownload(download_uid: string): void {
this.postsService.clearDownload(download_uid).subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to pause download! See server logs for more info.');
this.postsService.openSnackBar($localize`Failed to pause download! See server logs for more info.`);
}
});
}
watchContent(download): void {
watchContent(download: Download): void {
const container = download['container'];
localStorage.setItem('player_navigator', this.router.url.split(';')[0]);
const is_playlist = container['uids']; // hacky, TODO: fix
@@ -230,7 +231,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
}
}
combineDownloads(downloads_old, downloads_new) {
combineDownloads(downloads_old: Download[], downloads_new: Download[]): Download[] {
// only keeps downloads that exist in the new set
downloads_old = downloads_old.filter(download_old => downloads_new.some(download_new => download_new.uid === download_old.uid));
@@ -251,7 +252,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
return downloads_old;
}
showError(download) {
showError(download: Download): void {
const copyToClipboardEmitter = new EventEmitter<boolean>();
this.dialog.open(ConfirmDialogComponent, {
data: {
@@ -272,10 +273,3 @@ export class DownloadsComponent implements OnInit, OnDestroy {
});
}
}
export interface Download {
timestamp_start: number;
title: string;
step_index: number;
progress: string;
}

View File

@@ -43,17 +43,17 @@ export class LogsViewerComponent implements OnInit {
})
});
} else {
this.postsService.openSnackBar('Failed to retrieve logs!');
this.postsService.openSnackBar($localize`Failed to retrieve logs!`);
}
}, err => {
this.logs_loading = false;
console.error(err);
this.postsService.openSnackBar('Failed to retrieve logs!');
this.postsService.openSnackBar($localize`Failed to retrieve logs!`);
});
}
copiedLogsToClipboard() {
this.postsService.openSnackBar('Logs copied to clipboard!');
this.postsService.openSnackBar($localize`Logs copied to clipboard!`);
}
clearLogs() {
@@ -72,12 +72,12 @@ export class LogsViewerComponent implements OnInit {
this.logs = [];
this.logs_text = '';
this.getLogs();
this.postsService.openSnackBar('Logs successfully cleared!');
this.postsService.openSnackBar($localize`Logs successfully cleared!`);
} else {
this.postsService.openSnackBar('Failed to clear logs!');
this.postsService.openSnackBar($localize`Failed to clear logs!`);
}
}, err => {
this.postsService.openSnackBar('Failed to clear logs!');
this.postsService.openSnackBar($localize`Failed to clear logs!`);
});
}
});

View File

@@ -297,13 +297,13 @@ export class RecentVideosComponent implements OnInit {
deleteNormalFile(file, blacklistMode = false) {
this.postsService.deleteFile(file.uid, blacklistMode).subscribe(result => {
if (result) {
this.postsService.openSnackBar('Delete success!', 'OK.');
this.postsService.openSnackBar($localize`Delete success!', 'OK.`);
this.removeFileCard(file);
} else {
this.postsService.openSnackBar('Delete failed!', 'OK.');
this.postsService.openSnackBar($localize`Delete failed!', 'OK.`);
}
}, err => {
this.postsService.openSnackBar('Delete failed!', 'OK.');
this.postsService.openSnackBar($localize`Delete failed!', 'OK.`);
});
}

View File

@@ -96,18 +96,18 @@ export class TwitchChatComponent implements OnInit, OnDestroy {
let vodId = this.db_file.url.split('videos/').length > 1 && this.db_file.url.split('videos/')[1];
vodId = vodId.split('?')[0];
if (!vodId) {
this.postsService.openSnackBar('VOD url for this video is not supported. VOD ID must be after "twitch.tv/videos/"');
this.postsService.openSnackBar($localize`VOD url for this video is not supported. VOD ID must be after "twitch.tv/videos/"`);
}
this.postsService.downloadTwitchChat(this.db_file.id, this.db_file.isAudio ? 'audio' : 'video', vodId, null, this.sub).subscribe(res => {
if (res['chat']) {
this.initializeChatCheck(res['chat']);
} else {
this.downloading_chat = false;
this.postsService.openSnackBar('Download failed.')
this.postsService.openSnackBar($localize`Download failed.`)
}
}, err => {
this.downloading_chat = false;
this.postsService.openSnackBar('Chat could not be downloaded.')
this.postsService.openSnackBar($localize`Chat could not be downloaded.`)
});
}