Greatly improve localization automation workflow

Workflow previously:

- find and download VM image
	- Internet Archive / WinWorldPC
- make sure of language code (for instance, dk was actually da under the ISO standard)
	- https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
- move/rename so it's clear what it is
	- renaming it after creating the VM is complicated because it'll break virtualbox file references
- in command line, `bash ./localization/install-windows-98.sh <language code> `
- drag and drop iso into command line to complete the command
- attempt the command, and if it doesn't work, try other product keys or update the script as needed or install manually  
- close VM
- in command line, `bash ./localization/grab-files-from-vm.sh <language code> `
- drag and drop vdi into command line to complete the command
- run desktop automation, pressing Down at the appropriate time if there's a media notification like for YouTube
- close window
- go into Windows 10 VM
- find the new mspaint.exe
- right click, open resource tuner
- wait for it to load
- click the save multiple (batch export) button
- hit Next
- choose directory `Z:\extracted-resources\<language code>\mspaint`, creating the directories as needed
- hit Finish
- close window
- pause VM
- go to `/home/io/Downloads/Windowses/VirtualBox VMs/Win10 Share/extracted-resources/<language code>/mspaint`
- select Dialog, Menu, and String Table for now, maybe Accelerator Table later
- copy it to `/home/io/Projects/jspaint/localization/<language code>`, creating directory as needed
- run `npm run update-localization`
- add language to list of available languages in index.html (may become localization.js at some point)  
- test the new language
- commit

Workflow now:

- find and download VM image
	- Internet Archive / WinWorldPC
- make sure of language code (for instance, dk was actually da under the ISO standard)
	- https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
- move/rename so it's clear what it is
	- renaming it after creating the VM is complicated because it'll break virtualbox file references
- in command line, `bash ./localization/install-windows-98.sh <language code> `
- drag and drop iso into command line to complete the command
- attempt the command, and if it doesn't work, try other product keys or update the script as needed or install manually  
- close VM
- in command line, `bash ./localization/grab-files-from-vm.sh <language code>`
- run desktop automation, pressing Down at the appropriate time if there's a media notification like for YouTube
- test the new language
- commit
main
Isaiah Odhner 2020-12-13 16:12:36 -05:00
parent 83e7f8fcb2
commit 141d9f6b1a
3 changed files with 87 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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}"`);