Feature: add DeepLX translation support (#435)

Co-authored-by: Jason Lyu <xjasonlyu@gmail.com>
This commit is contained in:
zyd16888
2024-12-14 07:46:28 +08:00
committed by GitHub
parent 5023bebe9b
commit cf7594b731
3 changed files with 18 additions and 4 deletions

View File

@@ -168,6 +168,12 @@ public class PluginConfiguration : BasePluginConfiguration
#endif
public string DeepLApiKey { get; set; } = string.Empty;
#if __EMBY__
[DisplayName("DeepL alt url (optional)")]
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.DeepL)]
#endif
public string DeepLAltUrl { get; set; } = string.Empty;
#if __EMBY__
[DisplayName("OpenAI api key")]
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.OpenAi)]
@@ -245,4 +251,4 @@ public class PluginConfiguration : BasePluginConfiguration
}
private SubstitutionTable _genreSubstitutionTable;
}
}

View File

@@ -204,6 +204,11 @@
<input id="txtDeepLApiKey" is="emby-input" name="txtDeepLApiKey" type="text"/>
<div class="fieldDescription"></div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="txtDeepLAltUrl">DeepL alt url (optional):</label>
<input id="txtDeepLAltUrl" is="emby-input" name="txtDeepLAltUrl" type="text" />
<div class="fieldDescription"></div>
</div>
</div>
<div class="selectTranslationEngineOpenAi">
@@ -343,6 +348,7 @@
$('#txtBaiduAppKey', page).val(config.BaiduAppKey).change();
$('#txtGoogleApiKey', page).val(config.GoogleApiKey).change();
$('#txtDeepLApiKey', page).val(config.DeepLApiKey).change();
$('#txtDeepLAltUrl', page).val(config.DeepLAltUrl).change();
$('#txtOpenAiApiKey', page).val(config.OpenAiApiKey).change();
page.querySelector('#chkEnableTitleSubstitution').checked = config.EnableTitleSubstitution;
$('#txtTitleRawSubstitutionTable', page).val(config.TitleRawSubstitutionTable).change();
@@ -380,6 +386,7 @@
config.BaiduAppKey = $('#txtBaiduAppKey', form).val();
config.GoogleApiKey = $('#txtGoogleApiKey', form).val();
config.DeepLApiKey = $('#txtDeepLApiKey', form).val();
config.DeepLXAltUrl = $('#txtDeepLAltUrl', form).val();
config.OpenAiApiKey = $('#txtOpenAiApiKey', form).val();
config.EnableTitleSubstitution = $('#chkEnableTitleSubstitution', form).prop('checked');
config.TitleRawSubstitutionTable = $('#txtTitleRawSubstitutionTable', form).val();
@@ -395,4 +402,4 @@
</script>
</div>
</body>
</html>
</html>

View File

@@ -43,7 +43,8 @@ public static class TranslationHelper
millisecondsDelay = 100;
nv.Add(new NameValueCollection
{
{ "deepl-api-key", Configuration.DeepLApiKey }
{ "deepl-api-key", Configuration.DeepLApiKey },
{ "deepl-alt-url", Configuration.DeepLAltUrl }
});
break;
case TranslationEngine.OpenAi:
@@ -102,4 +103,4 @@ public static class TranslationHelper
}
}
}
}
}