code: def set_translation(lang):
      
      global translation
      # make list of possible languages, in order of preference
      langs = list()
      if lang:
          if '.' in lang:
              lang = lang.split('.')[0]
          langs += [lang, lang[:2]]
      # get translation object
      path = pkg_resources.resource_filename('pywws', 'lang')
      codeset = locale.getpreferredencoding()
      if codeset == 'ASCII':
          codeset = 'UTF-8'
      try:
          translation = gettext.translation(
              'pywws', path, languages=langs, codeset=codeset)
          # Python 3 translations don't have a ugettext method
          if not hasattr(translation, 'ugettext'):
              translation.ugettext = translation.gettext
      except IOError:
          return False
      return True
docs: Set the translation used by (some) pywws modules.
  
      This sets the translation object ``pywws.localisation.translation``
      to use a particular language.
  
      The ``lang`` parameter can be any string of the form ``en``,
      ``en_GB`` or ``en_GB.UTF-8``. Anything after a ``.`` character is
      ignored. In the case of a string such as ``en_GB``, the routine
      will search for an ``en_GB`` language file before searching for an
      ``en`` one.
  
      :param lang: language code.
      :type lang: string
      :return: success status.
      :rtype: bool