forked from WEIFENG2333/VideoCaptioner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
469 additions
and
352 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,81 @@ | ||
# Set the enums to new translated values | ||
from enum import Enum | ||
from PyQt5.QtCore import QObject | ||
from qfluentwidgets import ConfigValidator, ConfigSerializer | ||
from ..core.entities import SubtitleLayoutEnum, InternetTranslateEnum, TodoWhenDoneEnum, Task, BatchTaskTypeEnum | ||
|
||
class EnumOptionsValidator(ConfigValidator): | ||
""" Enum Options validator """ | ||
|
||
def __init__(self, enumClass: Enum): | ||
if not enumClass or len(enumClass) == 0: | ||
raise ValueError("The `enums` can't be empty.") | ||
|
||
if issubclass(enumClass, Enum): | ||
self.enumClass = enumClass | ||
else: | ||
self.enums = None | ||
|
||
def validate(self, enum): | ||
return enum in self.enumClass | ||
|
||
def correct(self, enum): | ||
return enum if self.validate(enum) else list(self.enumClass)[0] | ||
|
||
class EnumExSerializer(ConfigSerializer): | ||
""" enumeration class serializer for multi-language """ | ||
# It use names to serialize instead of values | ||
|
||
def __init__(self, enumClass): | ||
self.enumClass = enumClass | ||
|
||
def serialize(self, item): | ||
# From configItem.value to name | ||
return item.name | ||
|
||
def deserialize(self, name): | ||
# From name to configItem.value, which is an Enum | ||
return self.enumClass[name] | ||
|
||
def Enums_Translate(): | ||
qoEnums = QObject() | ||
BatchTaskTypeEnum.TRANSCRIBE._value_ = qoEnums.tr("Create Transcription from Audio/Video") | ||
BatchTaskTypeEnum.TRANSLATE._value_ = qoEnums.tr("Transcribe + Translate Audio/Video") | ||
BatchTaskTypeEnum.SOFT._value_ = qoEnums.tr("Create Soft Subtitle Video") | ||
BatchTaskTypeEnum.HARD._value_ = qoEnums.tr("Create Hard Subtitle Video") | ||
BatchTaskTypeEnum.TRANSCRIBE.setValue( qoEnums.tr("Create Transcription from Audio/Video") ) | ||
BatchTaskTypeEnum.TRANSLATE.setValue( qoEnums.tr("Transcribe + Translate Audio/Video") ) | ||
BatchTaskTypeEnum.SOFT.setValue( qoEnums.tr("Create Soft Subtitle Video") ) | ||
BatchTaskTypeEnum.HARD.setValue( qoEnums.tr("Create Hard Subtitle Video") ) | ||
|
||
SubtitleLayoutEnum.ONLY_ORIGINAL._value_ = qoEnums.tr("Original Only") | ||
SubtitleLayoutEnum.ONLY_TRANSLATE._value_ = qoEnums.tr("Translated Only") | ||
SubtitleLayoutEnum.ORIGINAL_ON_TOP._value_ = qoEnums.tr("Original on Top") | ||
SubtitleLayoutEnum.TRANSLATE_ON_TOP._value_ = qoEnums.tr("Translated on Top") | ||
SubtitleLayoutEnum.ONLY_ORIGINAL.setValue( qoEnums.tr("Original Only") ) | ||
SubtitleLayoutEnum.ONLY_TRANSLATE.setValue( qoEnums.tr("Translated Only") ) | ||
SubtitleLayoutEnum.ORIGINAL_ON_TOP.setValue( qoEnums.tr("Original on Top") ) | ||
SubtitleLayoutEnum.TRANSLATE_ON_TOP.setValue( qoEnums.tr("Translated on Top")) | ||
|
||
InternetTranslateEnum.GOOGLE._value_ = qoEnums.tr("Google Translate") | ||
InternetTranslateEnum.GOOGLE.setValue( qoEnums.tr("Google Translate")) | ||
|
||
TodoWhenDoneEnum.NOTHING._value_ = qoEnums.tr("Nothing") | ||
TodoWhenDoneEnum.EXIT._value_ = qoEnums.tr("Exit The Program") | ||
TodoWhenDoneEnum.SHUTDOWN._value_ = qoEnums.tr("Shutdown The Computer") | ||
TodoWhenDoneEnum.SUSPEND._value_ = qoEnums.tr("Suspend The Computer") | ||
TodoWhenDoneEnum.NOTHING.setValue( qoEnums.tr("Nothing")) | ||
TodoWhenDoneEnum.EXIT.setValue( qoEnums.tr("Exit The Program")) | ||
TodoWhenDoneEnum.SHUTDOWN.setValue( qoEnums.tr("Shutdown The Computer")) | ||
TodoWhenDoneEnum.SUSPEND.setValue( qoEnums.tr("Suspend The Computer")) | ||
|
||
Task.Status.CANCELED._value_ = qoEnums.tr("Canceled") | ||
Task.Status.COMPLETED._value_ = qoEnums.tr("Completed") | ||
Task.Status.DOWNLOADING._value_ = qoEnums.tr("Downloading") | ||
Task.Status.FAILED._value_ = qoEnums.tr("Failed") | ||
Task.Status.GENERATING._value_ = qoEnums.tr("Generating") | ||
Task.Status.OPTIMIZING._value_ = qoEnums.tr("Optimizing") | ||
Task.Status.PENDING._value_ = qoEnums.tr("Pending") | ||
Task.Status.SYNTHESIZING._value_ = qoEnums.tr("Synthesizing") | ||
Task.Status.TRANSCODING._value_ = qoEnums.tr("Transcoding") | ||
Task.Status.TRANSLATING._value_ = qoEnums.tr("Translating") | ||
Task.Status.WAITINGAUDIO._value_ = qoEnums.tr("Waiting for audio transcoding") | ||
Task.Status.WAITINGOPTIMIZE._value_ = qoEnums.tr("Waiting for optimization") | ||
Task.Status.WAITINGSYNTHESIS._value_ = qoEnums.tr("Waiting for video synthesis") | ||
Task.Status.WAITINGTRANSCRIBE._value_ = qoEnums.tr("Waiting for transcripting") | ||
|
||
Task.Source.FILE_IMPORT._value_ = qoEnums.tr("File Import") | ||
Task.Source.URL_IMPORT._value_ = qoEnums.tr("URL Import") | ||
Task.Status.CANCELED.setValue( qoEnums.tr("Canceled")) | ||
Task.Status.COMPLETED.setValue( qoEnums.tr("Completed")) | ||
Task.Status.DOWNLOADING.setValue( qoEnums.tr("Downloading")) | ||
Task.Status.FAILED.setValue( qoEnums.tr("Failed")) | ||
Task.Status.GENERATING.setValue( qoEnums.tr("Generating")) | ||
Task.Status.OPTIMIZING.setValue( qoEnums.tr("Optimizing")) | ||
Task.Status.PENDING.setValue( qoEnums.tr("Pending")) | ||
Task.Status.SYNTHESIZING.setValue( qoEnums.tr("Synthesizing")) | ||
Task.Status.TRANSCODING.setValue( qoEnums.tr("Transcoding")) | ||
Task.Status.TRANSLATING.setValue( qoEnums.tr("Translating")) | ||
Task.Status.WAITINGAUDIO.setValue( qoEnums.tr("Waiting for audio transcoding")) | ||
Task.Status.WAITINGOPTIMIZE.setValue( qoEnums.tr("Waiting for optimization")) | ||
Task.Status.WAITINGSYNTHESIS.setValue( qoEnums.tr("Waiting for video synthesis")) | ||
Task.Status.WAITINGTRANSCRIBE.setValue( qoEnums.tr("Waiting for transcripting")) | ||
|
||
Task.Source.FILE_IMPORT.setValue( qoEnums.tr("File Import")) | ||
Task.Source.URL_IMPORT.setValue( qoEnums.tr("URL Import")) | ||
|
||
Task.Type.OPTIMIZE._value_ = qoEnums.tr("Optimize + Translate Subtitles") | ||
Task.Type.SUBTITLE._value_ = qoEnums.tr("Add Subtitle To Video") | ||
Task.Type.SYNTHESIS._value_ = qoEnums.tr("Combine Subtitle with Video") | ||
Task.Type.TRANSCRIBE._value_ = qoEnums.tr("Get Subtitle From Video/Audio") | ||
Task.Type.URL._value_ = qoEnums.tr("Download Video from URL then Add Subtitle") | ||
Task.Type.OPTIMIZE.setValue( qoEnums.tr("Optimize + Translate Subtitles")) | ||
Task.Type.SUBTITLE.setValue( qoEnums.tr("Add Subtitle To Video")) | ||
Task.Type.SYNTHESIS.setValue( qoEnums.tr("Combine Subtitle with Video")) | ||
Task.Type.TRANSCRIBE.setValue( qoEnums.tr("Get Subtitle From Video/Audio")) | ||
Task.Type.URL.setValue( qoEnums.tr("Download Video from URL then Add Subtitle")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.