Template:IsLanguageCode/doc

Usage
Returns "true" if the first argument is a valid language code and whitespace/null in any other case.