code: def language_to_locale(language):
      
      tokens = language.split('-')
      if len(tokens) == 1:
          return tokens[0]
      return "%s_%s" % (tokens[0], tokens[1].upper())
docs: Converts django's `LANGUAGE_CODE` settings to a proper locale code.