create-update-and-edit-language.bat (2674B)
1 @ECHO OFF 2 REM Script to provide and easy way to update and edit .ts files for Duckstation. 3 REM Usage: drag and drop a duckstation .ts file on this batch file 4 REM Author: RaydenX93 5 REM Credits to Stenzek, Sam Pearman 6 TITLE Duckstation - Create, and Edit .ts files (Drag n Drop) 7 8 REM Check if an argument is provided 9 SET arg1="%~1" 10 IF %arg1%=="" GOTO noarg 11 12 REM get filename.extension and extension separately 13 FOR %%A IN (%arg1%) DO ( 14 SET filename=%%~nxA 15 SET ext=%%~xA 16 ) 17 18 REM Check if the file extension is .ts 19 IF %ext%==.ts GOTO goodfile 20 21 REM The wrong or no file has been passed 22 :noarg 23 ECHO =================================================================== 24 ECHO Duckstation - Create, Update and Edit .ts files (Drag n Drop) 25 ECHO =================================================================== 26 ECHO If you want to update and edit an EXISTING translation, drag and drop a .ts file on this batch file. 27 ECHO. 28 ECHO If you want to create a NEW translation, input (y) to start the process. 29 ECHO. 30 SET /P answ=Do you want to create a new translation? (y/n)... 31 32 IF %answ%==y (GOTO newlang) ELSE EXIT 33 34 :newlang 35 CLS 36 37 ECHO Please, insert your language code. 38 ECHO. 39 ECHO For the 369-1 2-digit language code: 40 ECHO https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 41 ECHO. 42 ECHO If you require a country code as well (you probably don't): 43 ECHO https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes 44 ECHO. 45 ECHO You can select with your mouse and then CTRL^+C to copy the links above. 46 ECHO. 47 ECHO Examples: 48 ECHO en ^<-- English 49 ECHO en-au ^<-- Australian English 50 ECHO. 51 52 SET /P langcode=Insert your language code... 53 54 CLS 55 IF NOT DEFINED langcode ( 56 ECHO Input is invalid. Try again. 57 ECHO. 58 PAUSE 59 GOTO newlang 60 ) ELSE ( 61 SET filename=duckstation-qt_%langcode%.ts 62 ) 63 64 REM A good .ts file has been passed 65 :goodfile 66 ECHO Updating %filename%... 67 ECHO. 68 SET "linguist=..\..\..\dep\msvc\deps-x64\bin" 69 SET "context=.././ ../../core/ ../../util/ -tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATE,QT_TRANSLATE_NOOP+=TRANSLATE_SV,QT_TRANSLATE_NOOP+=TRANSLATE_STR,QT_TRANSLATE_NOOP+=TRANSLATE_FS,QT_TRANSLATE_N_NOOP3+=TRANSLATE_FMT,QT_TRANSLATE_NOOP+=TRANSLATE_NOOP,translate+=TRANSLATE_PLURAL_STR,translate+=TRANSLATE_PLURAL_SSTR,translate+=TRANSLATE_PLURAL_FS" 70 71 "%linguist%\lupdate.exe" %context% -ts %filename% 72 ECHO. 73 PAUSE 74 75 CD "%linguist%" 76 START /B linguist.exe "%~dp0\%filename%" 77 78 REM References 79 REM https://stackoverflow.com/questions/9252980/how-to-split-the-filename-from-a-full-path-in-batch#9253018 80 REM https://stackoverflow.com/questions/26551/how-can-i-pass-arguments-to-a-batch-file 81 REM https://stackoverflow.com/questions/14786623/batch-file-copy-using-1-for-drag-and-drop