Alternative answer
If two keyboard layouts don't differ by many symbols, you could add Alt-modifiers for the foreign language (say, standard US Layout symbols on the Alt layer of a German keyboard) with a utility like AutoHotKey or similar.
Or, create a keymap for the OS which is the more correct way of doing it.
- never have to switch and wonder which language is active (can be very distracting)
- you may access the Alt layer often and this slows down your flow.
For some European languages, you could move characters permanently, instead of having a layer.
For example, [] and {} to Alt/Shift combos of () and [];:'" to keys near üäö, allowing you to keep an almost normal US layout for coding and make room for your languages' characters in the spots where they usually reside.