set path_script=%~dp0
echo %path_script%

call ${path_script}\..\..\..\..\init_qt_vsvars64.bat

cd %path_script%

md "%path_script%\ts"

@echo off
echo.&&echo.
setlocal enabledelayedexpansion
cd /d %path_script%\ts
echo Renaming .ts.xml files back to .ts...
for %%f in (*.ts.xml) do (
    set "fullname=%%~nf"
    set "original_name=!fullname:~0,-3!"
    ren "%%f" "!original_name!.ts"
    echo Renamed: %%f -^> !original_name!.ts
)
cd /d %path_script%
echo.&&echo.
endlocal

for %%i in ("en","zh_CN","zh_TW","ja","ko") do (
    lupdate -locations none -no-obsolete -recursive %path_script%\..\..\woterm %path_script%\..\..\kxftp %path_script%\..\..\kxvnc %path_script%\..\..\kxutil %path_script%\..\..\kxver  %path_script%\..\..\kxterm -ts %path_script%\ts\woterm_%%i.ts
   echo.&&echo.
)

for %%i in ("de","fr","ru","es") do (
    lupdate -locations none -no-obsolete -recursive %path_script%\..\..\woterm %path_script%\..\..\kxftp %path_script%\..\..\kxvnc %path_script%\..\..\kxutil %path_script%\..\..\kxver  %path_script%\..\..\kxterm -ts %path_script%\ts\woterm_%%i.ts
   echo.&&echo.
)

for %%i in ("id","hi") do (
    lupdate -locations none -no-obsolete -recursive %path_script%\..\..\woterm %path_script%\..\..\kxftp %path_script%\..\..\kxvnc %path_script%\..\..\kxutil %path_script%\..\..\kxver  %path_script%\..\..\kxterm -ts %path_script%\ts\woterm_%%i.ts
    echo.&&echo.
)

@echo off
setlocal enabledelayedexpansion
cd /d %path_script%\ts
for %%f in (*.ts) do (
    set "filename=%%~nf"
    set "extension=%%~xf"
    ren "%%f" "!filename!!extension!.xml"
    echo Renamed: %%f -^> !filename!!extension!.xml
)
cd /d %path_script%
echo.&&echo.
endlocal

pause