------------------------------------------------------------
# Get Input Source Language from menu bar input menu.
# Input menu icon must be visible in the menu bar.
------------------------------------------------------------
tell application "System Events"
if quit delay ≠ 0 then set quit delay to 0
tell application process "SystemUIServer"
tell menu bar 1
try
set inputMenu to first menu bar item whose accessibility description is "text input"
on error
error "The Input Menu is probably not visible in the menu bar."
end try
end tell
end tell
tell inputMenu to set inputLocale to its value
end tell
------------------------------------------------------------
I don't know of another method that is completely reliable, but if someone else does I'm interested.