@echo off
:: Very simple conversion from *.nsh to *.ts
setlocal
set Language=en
if "%1" NEQ "" set Language=%1
set InputFile=%~dp0..\%Language%.nsh
set OutputFile=%~dp0%Language%.ts
if not exist "%InputFile%" (
echo File %InputFile% not found.
goto :exit
)
echo ^ >"%OutputFile%"
echo ^ >>"%OutputFile%"
echo ^ >>"%OutputFile%"
for /F "tokens=1,2,3,*" %%A in (%InputFile%) do if "%%A"=="!insertmacro" call :context %%C %%D
echo ^ >>"%OutputFile%"
:exit
endlocal
goto :EOF
:context
setlocal EnableDelayedExpansion
:: Simple replace of & to &
set Text=%2
set Text=%Text:&=^&%
set Text=%Text:~1,-1%
echo !Text!
echo ^ >>"%OutputFile%"
echo ^%~1^ >>"%OutputFile%"
echo ^ >>"%OutputFile%"
echo ^ >>"%OutputFile%"
echo ^^ >>"%OutputFile%"
echo ^ >>"%OutputFile%"
echo ^ >>"%OutputFile%"
endlocal
goto :EOF