Feature: custom google translate url support (#495)

This commit is contained in:
zh-ww
2025-04-16 13:14:55 +08:00
committed by GitHub
parent c441ba43c8
commit bb9f0335a7
3 changed files with 16 additions and 1 deletions

View File

@@ -162,6 +162,13 @@ public class PluginConfiguration : BasePluginConfiguration
#endif
public string GoogleApiKey { get; set; } = string.Empty;
#if __EMBY__
[DisplayName("Google api url")]
[Description("Custom Google translate api url. (optional)")]
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.Google)]
#endif
public string GoogleApiUrl { get; set; } = string.Empty;
#if __EMBY__
[DisplayName("DeepL api key")]
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.DeepL)]

View File

@@ -196,6 +196,11 @@
<input id="txtGoogleApiKey" is="emby-input" name="txtGoogleApiKey" type="text"/>
<div class="fieldDescription"></div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="txtGoogleApiUrl">Google api url:</label>
<input id="txtGoogleApiUrl" is="emby-input" name="txtGoogleApiUrl" type="text"/>
<div class="fieldDescription">Custom Google translate api url. (optional)</div>
</div>
</div>
<div class="selectTranslationEngineDeepL">
@@ -357,6 +362,7 @@
$('#txtBaiduAppId', page).val(config.BaiduAppId).change();
$('#txtBaiduAppKey', page).val(config.BaiduAppKey).change();
$('#txtGoogleApiKey', page).val(config.GoogleApiKey).change();
$('#txtGoogleApiUrl', page).val(config.GoogleApiUrl).change();
$('#txtDeepLApiKey', page).val(config.DeepLApiKey).change();
$('#txtDeepLApiUrl', page).val(config.DeepLApiUrl).change();
$('#txtOpenAiApiKey', page).val(config.OpenAiApiKey).change();
@@ -397,6 +403,7 @@
config.BaiduAppId = $('#txtBaiduAppId', form).val();
config.BaiduAppKey = $('#txtBaiduAppKey', form).val();
config.GoogleApiKey = $('#txtGoogleApiKey', form).val();
config.GoogleApiUrl = $('#txtGoogleApiUrl', form).val();
config.DeepLApiKey = $('#txtDeepLApiKey', form).val();
config.DeepLXAltUrl = $('#txtDeepLApiUrl', form).val();
config.OpenAiApiKey = $('#txtOpenAiApiKey', form).val();

View File

@@ -32,7 +32,8 @@ public static class TranslationHelper
millisecondsDelay = 100; // Limit Google API request rate to 10 rps.
nv.Add(new NameValueCollection
{
{ "google-api-key", Configuration.GoogleApiKey }
{ "google-api-key", Configuration.GoogleApiKey },
{ "google-api-url", Configuration.GoogleApiUrl }
});
break;
case TranslationEngine.GoogleFree: