Download sample SRT files
' Open SRT file (subtitles) in Google Chrome to translate it
' Video
Set toolkit = CreateObject("VbsEdit.Toolkit")
files=toolkit.OpenFileDialog("","SRT Files (*.srt)|*.srt",False,"Open a subtitle file")
If UBound(files)<0 Then
Wscript.Quit
End If
source = files(0)
dest = source & ".htm"
Set objOutput = CreateObject("ADODB.Stream")
objOutput.Charset = "utf-8"
objOutput.Type = 2
objOutput.Open
objOutput.LineSeparator = -1
objOutput.WriteText "<html><body>",1
Set objInput = CreateObject("ADODB.Stream")
objInput.Charset = toolkit.charset(source)
objInput.Type = 2
objInput.LineSeparator = toolkit.lineseparator(source)
objInput.Open
objInput.LoadFromFile source
Do While True
If Not(objInput.EOS) Then
num = objInput.ReadText(-2)
Else
Exit Do
End If
objOutput.WriteText "<span class=""notranslate"">" & num & "</span><BR>",1
If Not(objInput.EOS) Then
tt = objInput.ReadText(-2)
Else
Exit Do
End If
objOutput.WriteText "<span class=""notranslate"">" & tt & "</span><BR>",1
Do While Not(objInput.EOS)
text = objInput.ReadText(-2)
objOutput.WriteText text & "<BR>",1
If text="" Then
Exit Do
End If
Loop
Loop
objInput.Close
objOutput.WriteText "</body></html>",1
objOutput.SaveToFile dest,2
objOutput.Close
Set WshShell = WScript.CreateObject("Wscript.Shell")
On Error Resume Next
chrome = wshshell.RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\")
If Err.number<>0 Then
chrome = wshshell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\")
End If
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
If fso.FileExists(chrome) Then
wshshell.Run """" & chrome & """ """ & dest & """",1,False
Else
WScript.Echo "could not locate Chrome."
End If