Skip to content

Commit

Permalink
SubtitleEditor: download button for subtitle; updated some locales fo…
Browse files Browse the repository at this point in the history
…r button title and tooltip
  • Loading branch information
Pavol Beskid committed Oct 15, 2023
1 parent 9685fcf commit d2e34fe
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/i18n/locales/cs-CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"time-duration-tooltip": "Video duration",
"duration-aria": "Duration",
"time-aria": "Current time",
"mutebutton-tooltip": "Mute video",
"unmutebutton-tooltip": "Unmute video",
"volume-tooltip": "Adjust volume: {{current}}%",
"volumeSlider-aria": "Adjust the volume level of the video.",
"comError-text": "A problem occurred during communication with Opencast.",
"loadError-text": "An error has occurred loading this video.",
"durationError-text": "Opencast failed to provide the video duration.",
Expand Down Expand Up @@ -228,6 +232,8 @@
"createSubtitleDropdown-label": "Pick a language",
"backButton": "Back",
"backButton-tooltip": "Return to subtitle selection",
"downloadButton-title": "Download",
"downloadButton-tooltip": "Download subtitle as vtt file",
"editTitle": "Subtitle Editor - {{title}}",
"editTitle-loading": "Loading",
"generic": "Generic",
Expand Down
10 changes: 6 additions & 4 deletions src/i18n/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"time-duration-tooltip": "Videodauer",
"duration-aria": "Dauer",
"time-aria": "Aktuelle Zeit",
"mutebutton-tooltip": "Video stummschalten",
"unmutebutton-tooltip": "Stummschaltung aufheben",
"volume-tooltip": "Lautstärke: {{current}}%",
"volumeSlider-aria": "Anpassen der Videolautstärke.",
"mutebutton-tooltip": "Mute video",
"unmutebutton-tooltip": "Unmute video",
"volume-tooltip": "Adjust volume: {{current}}%",
"volumeSlider-aria": "Adjust the volume level of the video.",
"comError-text": "Bei der Kommunikation mit Opencast ist ein Problem aufgetreten.",
"loadError-text": "Beim Laden des Videos ist ein Fehler aufgetreten.",
"durationError-text": "Opencast konnte die Video-Dauer nicht angeben.",
Expand Down Expand Up @@ -232,6 +232,8 @@
"createSubtitleDropdown-label": "Wähle eine Sprache",
"backButton": "Zurück",
"backButton-tooltip": "Zurück zur Untertitelauswahl",
"downloadButton-title": "Herunterladen",
"downloadButton-tooltip": "Untertitel als VTT-Datei herunterladen",
"editTitle": "Untertitel-Editor - {{title}}",
"editTitle-loading": "Lädt",
"generic": "Unspezifiziert",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/el-GR.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"time-duration-tooltip": "Διάρκεια βίντεο",
"duration-aria": "Διάρκεια",
"time-aria": "Τρέχουσα ώρα",
"mutebutton-tooltip": "Mute video",
"unmutebutton-tooltip": "Unmute video",
"volume-tooltip": "Adjust volume: {{current}}%",
"volumeSlider-aria": "Adjust the volume level of the video.",
"comError-text": "Προέκυψε πρόβλημα κατά την επικοινωνία με το Opencast.",
"loadError-text": "Παρουσιάστηκε σφάλμα κατά τηn φόρτωση του βίντεο.",
"durationError-text": "Opencast failed to provide the video duration.",
Expand Down Expand Up @@ -228,6 +232,8 @@
"createSubtitleDropdown-label": "Επιλέξτε μια γλώσσα",
"backButton": "Επιστροφή",
"backButton-tooltip": "Επιστροφή στην επιλογή υποτίτλων",
"downloadButton-title": "Κατεβάστε",
"downloadButton-tooltip": "Download subtitle as vtt file",
"editTitle": "Επεξεργαστής υποτίτλων - {{title}}",
"editTitle-loading": "Φόρτωση",
"generic": "Γενικά",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@
"createSubtitleDropdown-label": "Pick a language",
"backButton": "Back",
"backButton-tooltip": "Return to subtitle selection",
"downloadButton-title": "Download",
"downloadButton-tooltip": "Download subtitle as vtt file",
"editTitle": "Subtitle Editor - {{title}}",
"editTitle-loading": "Loading",
"generic": "Generic",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"time-duration-tooltip": "Duración del vídeo",
"duration-aria": "Duración",
"time-aria": "Tiempo actual",
"mutebutton-tooltip": "Mute video",
"unmutebutton-tooltip": "Unmute video",
"volume-tooltip": "Adjust volume: {{current}}%",
"volumeSlider-aria": "Adjust the volume level of the video.",
"comError-text": "Se ha producido un error al establecer comunicación con Opencast.",
"loadError-text": "Ocurrió un error al cargar el video.",
"durationError-text": "Opencast falló al proporcionar la duracion del vídeo.",
Expand Down Expand Up @@ -228,6 +232,8 @@
"createSubtitleDropdown-label": "Seleccione un idioma",
"backButton": "Atras",
"backButton-tooltip": "Volver a la selección de subtítulos",
"downloadButton-title": "Descargar",
"downloadButton-tooltip": "Download subtitle as vtt file",
"editTitle": "Editor de subtítulos - {{title}}",
"editTitle-loading": "Cargando",
"generic": "Generico",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"time-duration-tooltip": "Video duration",
"duration-aria": "Durée",
"time-aria": "Temps actuel",
"mutebutton-tooltip": "Mute video",
"unmutebutton-tooltip": "Unmute video",
"volume-tooltip": "Adjust volume: {{current}}%",
"volumeSlider-aria": "Adjust the volume level of the video.",
"comError-text": "Un problème est survenu lors de la communication avec Opencast.",
"loadError-text": "Une erreur s'est produite lors du chargement de cette vidéo.",
"durationError-text": "Opencast failed to provide the video duration.",
Expand Down Expand Up @@ -228,6 +232,8 @@
"createSubtitleDropdown-label": "Pick a language",
"backButton": "Back",
"backButton-tooltip": "Return to subtitle selection",
"downloadButton-title": "Download",
"downloadButton-tooltip": "Download subtitle as vtt file",
"editTitle": "Subtitle Editor - {{title}}",
"editTitle-loading": "Loading",
"generic": "Generic",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"time-duration-tooltip": "Video duration",
"duration-aria": "Duur",
"time-aria": "Actuele tijd",
"mutebutton-tooltip": "Mute video",
"unmutebutton-tooltip": "Unmute video",
"volume-tooltip": "Adjust volume: {{current}}%",
"volumeSlider-aria": "Adjust the volume level of the video.",
"comError-text": "Er is een probleem opgetreden tijdens de communicatie met Opencast.",
"loadError-text": "Er is een fout opgetreden tijdens het laden van deze video.",
"durationError-text": "Opencast failed to provide the video duration.",
Expand Down Expand Up @@ -228,6 +232,8 @@
"createSubtitleDropdown-label": "Pick a language",
"backButton": "Back",
"backButton-tooltip": "Return to subtitle selection",
"downloadButton-title": "Download",
"downloadButton-tooltip": "Download subtitle as vtt file",
"editTitle": "Subtitle Editor - {{title}}",
"editTitle-loading": "Loading",
"generic": "Generic",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"time-duration-tooltip": "Video duration",
"duration-aria": "Duration",
"time-aria": "Current time",
"mutebutton-tooltip": "Mute video",
"unmutebutton-tooltip": "Unmute video",
"volume-tooltip": "Adjust volume: {{current}}%",
"volumeSlider-aria": "Adjust the volume level of the video.",
"comError-text": "A problem occurred during communication with Opencast.",
"loadError-text": "An error has occurred loading this video.",
"durationError-text": "Opencast failed to provide the video duration.",
Expand Down Expand Up @@ -228,6 +232,8 @@
"createSubtitleDropdown-label": "Pick a language",
"backButton": "Back",
"backButton-tooltip": "Return to subtitle selection",
"downloadButton-title": "Download",
"downloadButton-tooltip": "Download subtitle as vtt file",
"editTitle": "Subtitle Editor - {{title}}",
"editTitle-loading": "Loading",
"generic": "Generic",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"time-duration-tooltip": "Video duration",
"duration-aria": "持續時間",
"time-aria": "目前時間",
"mutebutton-tooltip": "Mute video",
"unmutebutton-tooltip": "Unmute video",
"volume-tooltip": "Adjust volume: {{current}}%",
"volumeSlider-aria": "Adjust the volume level of the video.",
"comError-text": "與 Opencast 通訊時出現問題。",
"loadError-text": "載入此影片時出現錯誤。",
"durationError-text": "Opencast failed to provide the video duration.",
Expand Down Expand Up @@ -228,6 +232,8 @@
"createSubtitleDropdown-label": "Pick a language",
"backButton": "Back",
"backButton-tooltip": "Return to subtitle selection",
"downloadButton-title": "Download",
"downloadButton-tooltip": "Download subtitle as vtt file",
"editTitle": "Subtitle Editor - {{title}}",
"editTitle-loading": "Loading",
"generic": "Generic",
Expand Down
47 changes: 44 additions & 3 deletions src/main/SubtitleEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import { css } from "@emotion/react";
import { basicButtonStyle, flexGapReplacementStyle } from "../cssStyles";
import { LuChevronLeft} from "react-icons/lu";
import { LuChevronLeft, LuDownload} from "react-icons/lu";
import {
selectSubtitlesFromOpencastById,
} from '../redux/videoSlice'
Expand All @@ -17,7 +17,7 @@ import SubtitleVideoArea from "./SubtitleVideoArea";
import SubtitleTimeline from "./SubtitleTimeline";
import { useTranslation } from "react-i18next";
import { useTheme } from "../themes";
import { parseSubtitle } from "../util/utilityFunctions";
import { parseSubtitle, serializeSubtitle } from "../util/utilityFunctions";
import { ThemedTooltip } from "./Tooltip";
import { titleStyle, titleStyleBold } from "../cssStyles";
import { generateButtonTitle } from "./SubtitleSelect";
Expand Down Expand Up @@ -109,7 +109,7 @@ const SubtitleEditor : React.FC = () => {
<div css={[titleStyle(theme), titleStyleBold(theme)]}>
{t("subtitles.editTitle", {title: getTitle()})}
</div>
<div css={{width: '50px'}}></div>
<DownloadButton/>
</div>
<div css={subAreaStyle}>
<SubtitleListEditor />
Expand All @@ -128,6 +128,47 @@ const SubtitleEditor : React.FC = () => {
);
}

const DownloadButton: React.FC = () => {

const subtitle = useSelector(selectSelectedSubtitleById);

const downloadSubtitles = () => {

const vttFile = new Blob([serializeSubtitle(subtitle.cues)], {type: 'text/vtt'});

const vttFileLink = window.URL.createObjectURL(vttFile);
const vttHyperLink = document.createElement('a');
vttHyperLink.setAttribute('href', vttFileLink);

const vttFileName = generateButtonTitle(subtitle.tags, t).trimEnd();
vttHyperLink.setAttribute('download', `${vttFileName}.vtt`);
vttHyperLink.click();
}

const { t } = useTranslation();
const theme = useTheme();
const style = css({
fontSize: '16px',
height: '10px',
padding: '16px',
justifyContent: 'space-around',
boxShadow: `${theme.boxShadow}`,
background: `${theme.element_bg}`,
});

return (
<ThemedTooltip title={t("subtitles.downloadButton-tooltip")}>
<div css={[basicButtonStyle(theme), style]}
role="button"
onClick={() => downloadSubtitles()}
>
<LuDownload css={{fontSize: '16px'}}/>
<span>{t("subtitles.downloadButton-title")}</span>
</div>
</ThemedTooltip>
);
}


/**
* Takes you to a different page
Expand Down

0 comments on commit d2e34fe

Please sign in to comment.