@echo off & setlocal enableextensions & echo.

if not '%1'=='' goto getpar

:usage
echo Generates Intkey, info, and www files.
echo Usage: RUNLAN language
echo where 'language' is 'en' or 'fr'.
goto end

:getpar
for %%p in (en EN) do if %%p==%1 goto en
for %%p in (fr FR) do if %%p==%1 goto fr
goto usage

:en
set lan=en
goto start


:fr
set lan=fr
goto start

:start

call chkdiq_ %lan% || md %lan%
call chkdir_ %lan% || goto abort
call chkdiq_ %lan%\www || md %lan%\www
call chkdiq_ %lan%\info || md %lan%\info

echo.
echo ==============================================================================
echo ===== %lan% =====================================================================
echo ==============================================================================
echo.

echo Confor printch.%lan%
call confor printch.%lan% || goto abort
echo Confor toint.%lan%
call confor toint.%lan% || goto abort
echo Confor tonath.%lan%
call confor tonath.%lan% || goto abort
echo Confor tonatsr.%lan%
call confor tonatsr.%lan% || goto abort

cd %lan%

call findprog copgen > nul || goto skipped
goto copgen

:skipped
echo.
echo    Copying of general files from other Watson ^& Dallwitz datasets
echo    is not available. The files are already in this dataset.
goto finish

:copgen
call copgen || goto abort

:finish
cd ..
call finish %lan% && goto end

:abort
echo.
echo     ****** 'runlan.bat %lan%' failed.
exit /b 1

:end
exit /b 0
