-
Notifications
You must be signed in to change notification settings - Fork 44
/
Plugin.cs
68 lines (58 loc) · 2.11 KB
/
Plugin.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
63
64
65
66
67
68
using SubtitleEdit;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace Nikse.SubtitleEdit.PluginLogic
{
public class DeeplTranslate : IPlugin // dll file name must "<classname>.dll" - e.g. "Haxor.dll"
{
string IPlugin.Name
{
get { return "DeepL Translate"; }
}
string IPlugin.Text
{
get { return "Translate with DeepL.com"; }
}
decimal IPlugin.Version
{
get { return 0.93M; }
}
string IPlugin.Description
{
get { return "Translate subtitle with DeepL.com"; }
}
string IPlugin.ActionType // Can be one of these: file, tool, sync, translate, spellcheck
{
get { return "translate"; }
}
string IPlugin.Shortcut
{
get { return string.Empty; }
}
string IPlugin.DoAction(Form parentForm, string subtitle, double frameRate, string listViewLineSeparatorString, string subtitleFileName, string videoFileName, string rawText)
{
subtitle = subtitle.Trim();
if (string.IsNullOrEmpty(subtitle))
{
MessageBox.Show("No subtitle loaded", parentForm.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return string.Empty;
}
if (!string.IsNullOrEmpty(listViewLineSeparatorString))
Configuration.ListViewLineSeparatorString = listViewLineSeparatorString;
var list = new List<string>();
foreach (string line in subtitle.Replace(Environment.NewLine, "\n").Split('\n'))
list.Add(line);
var sub = new Subtitle();
var srt = new SubRip();
srt.LoadSubtitle(sub, list, subtitleFileName);
using (var form = new MainForm(sub, (this as IPlugin).Text, (this as IPlugin).Description, parentForm))
{
if (form.ShowDialog(parentForm) == DialogResult.OK)
return form.FixedSubtitle;
}
return string.Empty;
}
}
}