My partner needed an Alfred script to switch their Mac Catalina input source to Japanese using a keyboard shortcut because of the Moonlander.
After looking at a few (outdated) solutions on their forums and on the Internet, there didn't seem to be any reliable ones, so I just cobbled a script together.
*I'm not a Objective C developer so if you have any improvements, feel free to update this.
General idea is to get a list of your available input sources, iterate until we find one that has a localized name that matches the parameter you pass in, then set the input source to it.
If you have XCode installed and can use the command line, run the following:
clang -framework Carbon -framework Foundation input_switcher.m -o input_switcher
Then, setup Alfred to run the following commands on a key binding:
./input_switcher U.S.
./input_switcher Hiragana
Run it with no parameters to see what values you can pass in:
./input_switcher
(You'll probably need to give the binary some permissions.)
Enjoy! :D