Added function valid_language()

Added function valid_language() which checks whether a given language
exists in the enabled languages array or if it actually exists, and
implemented it in the checks.