We used to have several lines for detecting script based on the characters of the term given, in Module:utilities I think. Do you know where it is now?
It's now in Module:scripts.