@Dbenham , a big thanks for your good scripts -- it works on multi-lines with one empty line per sentence including .srt format that required timestamp before a sentence like this example:
1
00:00:24,827 --> 00:00:29,827
"My user-name can't be Bars!"
2
00:00:59,587 --> 00:01:04,587
My other user-name is Bars143!
here are my files to works on my assignment:
translation source file --> english-cebuano.txt
Code: Select all
my , ang akong
can't , 'ili
be , mao ang
other , uban
is , ay
input subtitle file --> english.srt
Code: Select all
1
00:00:24,827 --> 00:00:29,827
My user-name can't be Bars!
2
00:00:59,587 --> 00:01:04,587
My other user-name is Bars143!
output subtitle file -->cebuano.srt
Code: Select all
1
00:00:24,827 --> 00:00:29,827
Ang akong user-name 'ili mao ang Bars!
2
00:00:59,587 --> 00:01:04,587
Ang akong uban user-name ay Bars143!
but the actual subtile file can be 625 sentences/lines or above in one DVD movie.
i think it can be working on big srt file too.
here is my edited code based on your scripts added output file at the end of script:
Code: Select all
@echo off
setlocal
:: Delete any pre-existing _ variables
for /f "delims==" %%V in ('set _ 2^>nul') do set "%%V="
:: Load the dictionary
for /f "tokens=1* delims=, " %%A in (english-cebuano.txt) do set "_%%A=%%B"
:: Translate the text
call jrepl "(?:([A-Z])|[a-z0-9])(?:\S*[A-Za-z0-9])?" ^
"word=env('_'+$0)?env('_'+$0):$0;$1?word.slice(0,1).toUpperCase()+word.slice(1):word" ^
/j /f english.srt >cebuano.srt
Bars