code: def translate(word, config, use_cache=True, to_eng=False):
      
      translation = None
      data_dir = Path(config["data dir"])
  
      if use_cache:
          logger.debug("Checking cache: %s", word)
          translation = _cache_lookup(word, data_dir, native=to_eng)
  
      if translation:
          return translation
  
      html_dump = _lookup_online(word)
  
      try:
          translation = _parse_html(html_dump, native=to_eng)
      except WordNotFound as exn:
          logger.error(str(exn))
          raise exn
  
      _write_html_file(word, translation, data_dir, native=to_eng)
      if not to_eng:
          _save_to_history(word, data_dir)
          _write_index_file(data_dir)
  
      return translation
docs: Translate a word.
  
      Parameters
      ----------
      word : str
          Word to translate.
      config : Config
          Configuration settings.
      use_cache : bool, optional
          Wheter to use cache.
      to_eng : bool, optional
          Translate from Polish to English.
  
      Returns
      -------
      translation
          Translation of a word.
  
      Raises
      ------
      WordNotFound
          If word can't be found.