diff --git a/localization/grab-files-from-vm.sh b/localization/grab-files-from-vm.sh index c5ab48e..3425282 100644 --- a/localization/grab-files-from-vm.sh +++ b/localization/grab-files-from-vm.sh @@ -3,14 +3,21 @@ img_dir=/home/io/Downloads/Windowses/vdi-to-img img_file=$img_dir/Win98-$lang.vdi.img output_dir=/home/io/Downloads/Windowses/resources/$lang -if [ ! "$1" ] || [ ! "$2" ]; then - echo "Two arguments required: a target language code (e.g. en), and a path to a VirtualBox .vdi file or folder of a mounted .img" +if [ ! "$1" ]; then + echo "One argument required: a target language code (e.g. en)" exit 1 fi -if [ -d "$2" ]; then +if [ ! "$2" ]; then + vdi_file="/home/io/VirtualBox VMs/Win98-$lang/Win98-$lang.vdi" +elif [ -d "$2" ]; then mount_dir=$2 elif [ -f "$2" ]; then vdi_file=$2 +else + echo "No file or directory at \"$2\"!" + exit 1 +fi +if [ ! "$mount_dir" ]; then if [ ! -d "$img_dir" ]; then mkdir -p "$img_dir" fi @@ -39,13 +46,13 @@ elif [ -f "$2" ]; then echo "Waiting for window \"vdi-to-img\"" xdotool search --sync --name "vdi-to-img" windowactivate --sync echo "Found window \"vdi-to-img\"" - sleep 1 - xdotool key --clearmodifiers Return sleep 5 + xdotool key --clearmodifiers Return + sleep 1 echo "Click on notification to go to mounted folder" echo "If the wrong notification is selected, quick, use the arrow keys!" xdotool key --clearmodifiers Super_L+v - sleep 5 + sleep 15 # time to select appropriate notification xdotool key --clearmodifiers Return sleep 0.5 xdotool key --clearmodifiers Escape @@ -55,20 +62,23 @@ elif [ -f "$2" ]; then # xdotool search --sync --name "Win98-$lang.vdi" windowactivate --sync # echo "Found window \"Win98-$lang.vdi\"" # sleep 1 + echo "Copy path of mounted folder" xdotool key --clearmodifiers ctrl+l sleep 1 old_clipboard=`xclip -selection clipboard -o` xdotool key --clearmodifiers ctrl+c - sleep 1 + sleep 0.5 mount_dir=`xclip -selection clipboard -o` - printf "$old_clipboard" | xclip -selection clipboard + cat "$old_clipboard" | xclip -selection clipboard + echo "(Restored clipboard text)" + echo "Close mounted folder window" + xdotool key --clearmodifiers alt+F4 + echo "Close vdi-to-img folder window" + wmctrl -c "vdi-to-img" if [ ! -d "$mount_dir" ]; then echo "Failed to get path of mounted directory, or failed to mount. \"$mount_dir\" is not a directory." exit 1 fi -else - echo "No file or directory at \"$2\"!" - exit 1 fi if [ ! -d "$output_dir" ]; then mkdir -p "$output_dir" @@ -120,8 +130,56 @@ grab "mspaint.exe" # "C:\\Program Files\\Accessories\\mspaint.exe" grab "wordpad.exe" # "C:\\Program Files\\Accessories\\wordpad.exe" grab "Write.exe" # "C:\\Windows\\Write.exe" +echo "Grabbed files, now copy them to the Windows 10 VM shared folder" rsync -av --exclude='HELP/' "/home/io/Downloads/Windowses/resources" "/home/io/VirtualBox VMs/Win10 Share" +echo "Go to Windows 10 VM" +VBoxManage controlvm "Windows 10" resume +xdotool search --sync --name "Windows 10 (\(.*\) )?\[Running\]" windowactivate --sync +sleep 1 +echo "Open Run dialog" +xdotool key --clearmodifiers --delay 20 Super_L+r +sleep 1 +echo "Open Resource Tuner for the localized mspaint.exe" +xdotool type --delay 20 "C:\\Program Files (x86)\\Resource Tuner\\restuner.exe Z:\\resources\\$lang\\mspaint.exe" +sleep 0.3 +xdotool key --clearmodifiers Return +sleep 10 +echo "Open \"Save Multiple Resources At Once\" batch export dialog" +xdotool key --clearmodifiers --delay 20 ctrl+shift+m +sleep 2 +echo "Settings should be already selected; Next" +xdotool key --clearmodifiers --delay 20 alt+n +sleep 2 +echo "Enter output folder" +xdotool key --clearmodifiers --delay 20 Tab +sleep 0.2 +xdotool key --clearmodifiers --delay 20 Tab +sleep 0.2 +xdotool key --clearmodifiers --delay 20 Tab +sleep 0.2 +# It will create these folders automatically :) +xdotool type "Z:\\extracted-resources\\$lang\\mspaint" +sleep 0.2 +echo "Finish" +xdotool key --clearmodifiers Return +sleep 1 +echo "Close Resource Tuner" +xdotool key --clearmodifiers alt+F4 +sleep 1 +echo "Pause the VM" +VBoxManage controlvm "Windows 10" pause + +echo "Copy extracted strings out of the VM shared folder" +mkdir -p "/home/io/Projects/jspaint/localization/$lang" +cp -r "/home/io/VirtualBox VMs/Win10 Share/extracted-resources/$lang/mspaint/Dialog" "/home/io/Projects/jspaint/localization/$lang" +cp -r "/home/io/VirtualBox VMs/Win10 Share/extracted-resources/$lang/mspaint/Menu" "/home/io/Projects/jspaint/localization/$lang" +cp -r "/home/io/VirtualBox VMs/Win10 Share/extracted-resources/$lang/mspaint/String Table" "/home/io/Projects/jspaint/localization/$lang" +echo "Rebuild localization files in jspaint" +cd "/home/io/Projects/jspaint" +npm run update-localization +echo "DONE! Now just test the new language in jspaint and commit!" + # TODO: find where strings are stored for: # - The Edit Colors dialog text # - The Help viewer text diff --git a/localization/install-windows-98.sh b/localization/install-windows-98.sh index 4fa77cb..c820d71 100644 --- a/localization/install-windows-98.sh +++ b/localization/install-windows-98.sh @@ -5,11 +5,11 @@ # I knew there would be sysadmin type ways of doing this, but I went this route I guess because I thought it was cool. # It's a lot of work tho, and way less reliable. -target_lang=$1 +lang=$1 target_os_iso=$2 -vm_name="Win98-${target_lang}" +vm_name="Win98-${lang}" already_got_image=false -if [ ! "$target_lang" ] || [ ! "$target_os_iso" ]; then +if [ ! "$lang" ] || [ ! "$target_os_iso" ]; then echo "Two arguments required: a target language code (e.g. en), and a path to an iso file." exit 1 fi @@ -80,8 +80,13 @@ boot_into_setup(){ sleep 0.5 xdotool key --clearmodifiers --delay 20 Return sleep 2 - echo "Select 1. Start Windows 98 Setup from CD ROM" - xdotool key --clearmodifiers --delay 20 1 + if [ "$lang" = "he" ]; then + echo "Select 2. Start Localized Windows 98 Setup from CD ROM" + xdotool key --clearmodifiers --delay 20 2 + else + echo "Select 1. Start Windows 98 Setup from CD ROM" + xdotool key --clearmodifiers --delay 20 1 + fi sleep 0.5 xdotool key --clearmodifiers --delay 20 Return } @@ -304,6 +309,7 @@ xdotool type --delay 20 "B8MFRCFTGQC9PBWVHG3J3R3YW" # One liner to enter a key in case you need to try several keys: # xdotool search --sync --name "Win98-ja \[Running\] - Oracle VM VirtualBox" windowactivate --sync type --delay 20 "K4HVDQ9TJ96CRX9C9G68RQ2D3" +# xdotool search --sync --name "Win98-he \[Running\] - Oracle VM VirtualBox" windowactivate --sync type --delay 20 "B8MFRCFTGQC9PBWVHG3J3R3YW" sleep 0.5 xdotool key --clearmodifiers --delay 20 Return diff --git a/localization/preprocess.js b/localization/preprocess.js index 956adda..84917e6 100644 --- a/localization/preprocess.js +++ b/localization/preprocess.js @@ -81,3 +81,10 @@ for (const target_lang of target_langs) { const js = `loaded_localizations("${target_lang}", ${JSON.stringify(localizations, null, "\t")});\n`; fs.writeFileSync(`${__dirname}/${target_lang}/localizations.js`, js); } + +// Update available_languages list automatically! +const file = require("path").resolve(__dirname + "/../index.html"); +let code = fs.readFileSync(file, "utf8"); +code = code.replace(/(available_languages\s*=\s*)\[[^\]]*\]/, `$1${JSON.stringify(available_langs).replace(/","/g, `", "`)}`); +fs.writeFileSync(file, code, "utf8"); +console.log(`Updated available_languages list in "${file}"`);