For your client you can use GetLocale().
For your target (or any unit) you could match their realm against the ones available. The list would map their realm name to their locale.
I think I saw a library doing something like that around.
Yup,
http://www.wowinterface.com/download...RealmInfo.html