feat(glossary): add episode groups, search, and import/export
Apply glossary edits directly to translated subtitles and reload the active track. Keep terms with their originating episode, preserve existing translations, and clear stale episode groups with glossary entries.
This commit is contained in:
1 parent
0bfaf3c9db
commit
97b4a2fe32
9 files changed
+955
-50
No files matched your search
+22
-4
@@ -20,6 +20,11 @@ ApplicationWindow {
|
||||
|
||||
property int previousVisibility: Window.Windowed
|
||||
readonly property bool isFullScreen: visibility === Window.FullScreen
|
||||
// Keep the original subtitle track so glossary edits update the generated
|
||||
// subtitle even while that translated track is selected in mpv.
|
||||
property var lastTranslationTrack: null
|
||||
property url lastTranslationVideo: ""
|
||||
property var translatedSubtitleUrls: []
|
||||
|
||||
function openFile(url: url) {
|
||||
playlistModel.openFile(url, QtPotatoSettings.playlistLoadSiblings)
|
||||
@@ -42,8 +47,13 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
function translateCurrentSubtitle() {
|
||||
const track = video.subtitleTracks.find(track => track.id === video.subtitleId)
|
||||
let track = video.subtitleTracks.find(track => track.id === video.subtitleId)
|
||||
if (track && translatedSubtitleUrls.includes(track.externalFilename) && lastTranslationTrack) {
|
||||
track = video.subtitleTracks.find(track => track.id === lastTranslationTrack.id)
|
||||
}
|
||||
if (track) {
|
||||
lastTranslationTrack = track
|
||||
lastTranslationVideo = video.currentUrl
|
||||
translationService.translate(video.currentUrl, track, video.mediaTitle)
|
||||
}
|
||||
}
|
||||
@@ -154,6 +164,8 @@ ApplicationWindow {
|
||||
TranslationService {
|
||||
id: translationService
|
||||
onTranslated: (subtitleUrl, fromCache) => {
|
||||
// mpv exposes local external subtitle filenames as filesystem paths.
|
||||
appWindow.translatedSubtitleUrls.push(decodeURIComponent(subtitleUrl.toString().replace(/^file:\/\//, "")))
|
||||
video.showTranslatedSubtitleFile(subtitleUrl,
|
||||
KI18n.i18nc("@item:inlistbox subtitle track, %1 is a language", "%1 (translated)", QtPotatoSettings.targetLanguage))
|
||||
osdItem.message(fromCache
|
||||
@@ -165,6 +177,15 @@ ApplicationWindow {
|
||||
MpvVideo {
|
||||
id: video
|
||||
|
||||
onCurrentUrlChanged: {
|
||||
translationService.cancel()
|
||||
translationService.forgetTranslation()
|
||||
appWindow.lastTranslationTrack = null
|
||||
appWindow.lastTranslationVideo = ""
|
||||
appWindow.translatedSubtitleUrls = []
|
||||
glossaryDialog.close()
|
||||
}
|
||||
|
||||
actions: appActions
|
||||
fullscreen: appWindow.isFullScreen
|
||||
|
||||
@@ -208,9 +229,6 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// A translation belongs to the file it was started for.
|
||||
onCurrentUrlChanged: translationService.cancel()
|
||||
|
||||
Osd {
|
||||
id: osdItem
|
||||
maxWidth: video.width
|
||||
|
||||
Reference in new issue
Block a user