-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSetting.cs
62 lines (59 loc) · 1.59 KB
/
Setting.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LinePutScript.Converter;
namespace VPet.Plugin.AutoMTL
{
public class Setting
{
/// <summary>
/// Enables title case for the returned translations (needs restart + cache clear)
/// </summary>
[Line]
public bool titleCase { get; set; } = true;
/// <summary>
/// The time between translation requests in ms
/// </summary>
[Line]
public long waitMs { get; set; } = 2;
/// <summary>
/// Translation provider Id
/// </summary>
[Line]
public string providerId { get; set; } = "google";
/// <summary>
/// Source Language
/// </summary>
[Line]
public string srcLangId { get; set; } = "auto";
/// <summary>
/// Destination Language
/// </summary>
[Line]
public string dstLangId { get; set; } = "en";
/// <summary>
/// Enable the Automatic Machine Translation (needs restart)
/// </summary>
[Line]
public bool enabled { get; set; } = true;
public void sanitize()
{
if (!TranslatorMananger.translatorNames.ContainsKey(providerId))
providerId = "google";
Dictionary<string, string> langs = TranslatorMananger.getTranslatorLangs(providerId);
if (!langs.ContainsKey(srcLangId))
srcLangId= "auto";
if (!langs.ContainsKey(dstLangId))
srcLangId = "en";
}
public TranslatorBase createTranslator(string cacheBase)
{
TranslatorBase trans = TranslatorMananger.constructTranslator(providerId, srcLangId, dstLangId, cacheBase);
trans.msBetweenCalls = waitMs;
trans.titleCase = titleCase;
return trans;
}
}
}