Shell script to toggle spelling language

I realize that I am totally off topic.
NSSpellChecker only creates an instance of the spell checking system for the current host.
The settings can only be changed for the current script or application.

Sorry for the false hope…

No worries. Thanks for looking into it.

No one has been able to figure it out yet. Changing the spelling language manually through system settings makes open apps see the change, so it has to be possible programmatically.

If only Apple provided an easy way to do this natively…