|
|
|
@ -85,16 +85,16 @@ namespace STranslate.ViewModel
|
|
|
|
|
{
|
|
|
|
|
Speech.SpeakAsync(InputTxt);
|
|
|
|
|
});
|
|
|
|
|
//target speak
|
|
|
|
|
TargetSpeakCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
|
Speech.SpeakAsync(OutputTxt);
|
|
|
|
|
});
|
|
|
|
|
//复制输入
|
|
|
|
|
CopyInputCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetText(InputTxt);
|
|
|
|
|
});
|
|
|
|
|
//target speak
|
|
|
|
|
TargetSpeakCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
|
Speech.SpeakAsync(OutputTxt);
|
|
|
|
|
});
|
|
|
|
|
//复制翻译结果
|
|
|
|
|
CopyResultCmd = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
@ -115,6 +115,31 @@ namespace STranslate.ViewModel
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetText(LargeHumpRet);
|
|
|
|
|
});
|
|
|
|
|
//target speak
|
|
|
|
|
TargetSpeakCmd2 = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
|
Speech.SpeakAsync(OutputTxt2);
|
|
|
|
|
});
|
|
|
|
|
//复制翻译结果
|
|
|
|
|
CopyResultCmd2 = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetText(OutputTxt2);
|
|
|
|
|
});
|
|
|
|
|
//复制蛇形结果
|
|
|
|
|
CopySnakeResultCmd2 = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetText(SnakeRet2);
|
|
|
|
|
});
|
|
|
|
|
//复制小驼峰结果
|
|
|
|
|
CopySmallHumpResultCmd2 = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetText(SmallHumpRet2);
|
|
|
|
|
});
|
|
|
|
|
//复制大驼峰结果
|
|
|
|
|
CopyLargeHumpResultCmd2 = new RelayCommand((_) => true, (_) =>
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetText(LargeHumpRet2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//主题切换
|
|
|
|
|
ThemeConvertCmd = new RelayCommand((_) => true, (o) =>
|
|
|
|
@ -143,9 +168,13 @@ namespace STranslate.ViewModel
|
|
|
|
|
{
|
|
|
|
|
InputTxt = string.Empty;
|
|
|
|
|
OutputTxt = string.Empty;
|
|
|
|
|
OutputTxt2 = string.Empty;
|
|
|
|
|
SnakeRet = string.Empty;
|
|
|
|
|
SmallHumpRet = string.Empty;
|
|
|
|
|
LargeHumpRet = string.Empty;
|
|
|
|
|
SnakeRet2 = string.Empty;
|
|
|
|
|
SmallHumpRet2 = string.Empty;
|
|
|
|
|
LargeHumpRet2 = string.Empty;
|
|
|
|
|
IdentifyLanguage = string.Empty;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -268,6 +297,7 @@ namespace STranslate.ViewModel
|
|
|
|
|
TargetLanguage = OutputComboSelected,
|
|
|
|
|
SelectServer = TranslationInterface.FindIndex(x => x == SelectedTranslationInterface),
|
|
|
|
|
Servers = _GlobalConfig.Servers,
|
|
|
|
|
BaiduServers = _GlobalConfig.BaiduServers,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -321,10 +351,12 @@ namespace STranslate.ViewModel
|
|
|
|
|
var isEng = string.Empty;
|
|
|
|
|
IdentifyLanguage = string.Empty;
|
|
|
|
|
OutputTxt = "翻译中...";
|
|
|
|
|
OutputTxt2 = "翻译中...";
|
|
|
|
|
//清空多种复制
|
|
|
|
|
SnakeRet = string.Empty;
|
|
|
|
|
SmallHumpRet = string.Empty;
|
|
|
|
|
LargeHumpRet = string.Empty;
|
|
|
|
|
var translateResp2 = string.Empty;
|
|
|
|
|
|
|
|
|
|
//自动选择目标语言
|
|
|
|
|
if (OutputComboSelected == LanguageEnum.AUTO.GetDescription())
|
|
|
|
@ -333,20 +365,29 @@ namespace STranslate.ViewModel
|
|
|
|
|
IdentifyLanguage = autoRet.Item1;
|
|
|
|
|
isEng = autoRet.Item2;
|
|
|
|
|
translateResp = await Util.Util.TranslateDeepLAsync(SelectedTranslationInterface.Api, InputTxt, LanguageEnumDict[autoRet.Item2], LanguageEnumDict[InputComboSelected]);
|
|
|
|
|
translateResp2 = await Util.Util.TranslateBaiduAsync(_GlobalConfig.BaiduServers.Appid, _GlobalConfig.BaiduServers.SecretKey, InputTxt, LanguageEnumDict[autoRet.Item2], LanguageEnumDict[InputComboSelected]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
translateResp = await Util.Util.TranslateDeepLAsync(SelectedTranslationInterface.Api, InputTxt, LanguageEnumDict[OutputComboSelected], LanguageEnumDict[InputComboSelected]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//百度 Api
|
|
|
|
|
//var translateResp = await TranslateUtil.TranslateBaiduAsync(config.baidu.appid, config.baidu.secretKey, InputTxt, LanguageEnumDict[OutputComboSelected], LanguageEnumDict[InputComboSelected]);
|
|
|
|
|
translateResp2 = await Util.Util.TranslateBaiduAsync(_GlobalConfig.BaiduServers.Appid, _GlobalConfig.BaiduServers.SecretKey, InputTxt, LanguageEnumDict[OutputComboSelected], LanguageEnumDict[InputComboSelected]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (translateResp == string.Empty)
|
|
|
|
|
{
|
|
|
|
|
OutputTxt = "翻译出错,请稍候再试...";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (translateResp2 == string.Empty)
|
|
|
|
|
{
|
|
|
|
|
OutputTxt2 = "翻译出错,请稍候再试...";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
OutputTxt = translateResp;
|
|
|
|
|
OutputTxt2 = translateResp2;
|
|
|
|
|
|
|
|
|
|
//如果目标语言不是英文则不进行转换
|
|
|
|
|
//1. 自动判断语种:Tuple item2 不为 EN
|
|
|
|
@ -367,11 +408,20 @@ namespace STranslate.ViewModel
|
|
|
|
|
SmallHumpRet = Util.Util.GenHumpString(splitList, true); //小驼峰
|
|
|
|
|
LargeHumpRet = Util.Util.GenHumpString(splitList, false); //大驼峰
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var splitList2 = OutputTxt2.Split(' ').ToList();
|
|
|
|
|
if (splitList2.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
SnakeRet2 = Util.Util.GenSnakeString(splitList);
|
|
|
|
|
SmallHumpRet2 = Util.Util.GenHumpString(splitList, true); //小驼峰
|
|
|
|
|
LargeHumpRet2 = Util.Util.GenHumpString(splitList, false); //大驼峰
|
|
|
|
|
}
|
|
|
|
|
//System.Diagnostics.Debug.Print(SnakeRet + "\n" + SmallHumpRet + "\n" + LargeHumpRet);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
OutputTxt = ex.Message;
|
|
|
|
|
OutputTxt2 = ex.Message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion handle
|
|
|
|
@ -382,12 +432,17 @@ namespace STranslate.ViewModel
|
|
|
|
|
public ICommand DeactivatedCmd { get; private set; }
|
|
|
|
|
public ICommand SourceSpeakCmd { get; private set; }
|
|
|
|
|
public ICommand TargetSpeakCmd { get; private set; }
|
|
|
|
|
public ICommand TargetSpeakCmd2 { get; private set; }
|
|
|
|
|
public ICommand TranslateCmd { get; private set; }
|
|
|
|
|
public ICommand CopyInputCmd { get; private set; }
|
|
|
|
|
public ICommand CopyResultCmd { get; private set; }
|
|
|
|
|
public ICommand CopySnakeResultCmd { get; private set; }
|
|
|
|
|
public ICommand CopySmallHumpResultCmd { get; private set; }
|
|
|
|
|
public ICommand CopyLargeHumpResultCmd { get; private set; }
|
|
|
|
|
public ICommand CopyResultCmd2 { get; private set; }
|
|
|
|
|
public ICommand CopySnakeResultCmd2 { get; private set; }
|
|
|
|
|
public ICommand CopySmallHumpResultCmd2 { get; private set; }
|
|
|
|
|
public ICommand CopyLargeHumpResultCmd2 { get; private set; }
|
|
|
|
|
public ICommand ThemeConvertCmd { get; private set; }
|
|
|
|
|
public ICommand TopmostCmd { get; private set; }
|
|
|
|
|
public ICommand EscCmd { get; private set; }
|
|
|
|
@ -422,6 +477,11 @@ namespace STranslate.ViewModel
|
|
|
|
|
private string _SnakeRet;
|
|
|
|
|
public string SnakeRet { get => _SnakeRet; set => UpdateProperty(ref _SnakeRet, value); }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造蛇形结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _SnakeRet2;
|
|
|
|
|
public string SnakeRet2 { get => _SnakeRet2; set => UpdateProperty(ref _SnakeRet2, value); }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造驼峰结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _SmallHumpRet;
|
|
|
|
@ -429,8 +489,18 @@ namespace STranslate.ViewModel
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造驼峰结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _SmallHumpRet2;
|
|
|
|
|
public string SmallHumpRet2 { get => _SmallHumpRet2; set => UpdateProperty(ref _SmallHumpRet2, value); }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造驼峰结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _LargeHumpRet;
|
|
|
|
|
public string LargeHumpRet { get => _LargeHumpRet; set => UpdateProperty(ref _LargeHumpRet, value); }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造驼峰结果2
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _LargeHumpRet2;
|
|
|
|
|
public string LargeHumpRet2 { get => _LargeHumpRet2; set => UpdateProperty(ref _LargeHumpRet2, value); }
|
|
|
|
|
|
|
|
|
|
private string _InputTxt;
|
|
|
|
|
public string InputTxt { get => _InputTxt; set => UpdateProperty(ref _InputTxt, value); }
|
|
|
|
@ -438,6 +508,9 @@ namespace STranslate.ViewModel
|
|
|
|
|
private string _OutputTxt;
|
|
|
|
|
public string OutputTxt { get => _OutputTxt; set => UpdateProperty(ref _OutputTxt, value); }
|
|
|
|
|
|
|
|
|
|
private string _OutputTxt2;
|
|
|
|
|
public string OutputTxt2 { get => _OutputTxt2; set => UpdateProperty(ref _OutputTxt2, value); }
|
|
|
|
|
|
|
|
|
|
private List<string> _InputCombo;
|
|
|
|
|
public List<string> InputCombo { get => _InputCombo; set => UpdateProperty(ref _InputCombo, value); }
|
|
|
|
|
|
|
|
|
|