code: def detect(self, text):
          
          if isinstance(text, list):
              result = []
              for item in text:
                  lang = self.detect(item)
                  result.append(lang)
              return result
  
          data = self._translate(text, dest='en', src='auto')
  
          # actual source language that will be recognized by Google Translator when the
          # src passed is equal to auto.
          src = ''
          confidence = 0.0
          try:
              src = ''.join(data[8][0])
              confidence = data[8][-2][0]
          except Exception:  # pragma: nocover
              pass
          result = Detected(lang=src, confidence=confidence)
  
          return result
docs: Detect language of the input text
  
          :param text: The source text(s) whose language you want to identify.
                       Batch detection is supported via sequence input.
          :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, iterator, generator)
  
          :rtype: Detected
          :rtype: :class:`list` (when a list is passed)
  
          Basic usage:
              >>> from googletrans import Translator
              >>> translator = Translator()
              >>> translator.detect('이 문장은 한글로 쓰여졌습니다.')
              <Detected lang=ko confidence=0.27041003>
              >>> translator.detect('この文章は日本語で書かれました。')
              <Detected lang=ja confidence=0.64889508>
              >>> translator.detect('This sentence is written in English.')
              <Detected lang=en confidence=0.22348526>
              >>> translator.detect('Tiu frazo estas skribita en Esperanto.')
              <Detected lang=eo confidence=0.10538048>
  
          Advanced usage:
              >>> langs = translator.detect(['한국어', '日本語', 'English', 'le français'])
              >>> for lang in langs:
              ...    print(lang.lang, lang.confidence)
              ko 1
              ja 0.92929292
              en 0.96954316
              fr 0.043500196