Is it possible to do this on Mac? Have a second, external keyboard mapped to a different language than the primary keyboard?
There's a tomscott video on it
https://www.youtube.com/watch?v=lIFE7h3m40U
Checkout Teran van Hemert (linustechtips editor) for some potential ideas too. He's got crazy macro schemas, I've used a couple of his and there great. All windows based as well though. https://www.youtube.com/playlist?list=PLH1gH0v9E3ruYrNyRbHhD...
Mac, I can only assume its something you would write in applescript. But maybe you find some interesting ideas there. I found something called "http://www.orderedbytes.com/controllermate/" that might be of interest to you