keyboard – How to make input source switching per-app or per-window, not global?

I use two input sources: A and B. I’m talking to my colleagues in a messenger using language A; and at the same time I’m working in a terminal using language B. It’s very annoying to switch from the messenger to the terminal and have A; and likewise to switch to the messenger and have B. Is there a way to preserve the current input source per-app or per-window?

This is macOS Catalina 10.15.6 on a MacBook Pro 2019.