docs: def translation(self, bundleId, languages, priority='gp', domain=None,
          localedir=None, class_=None, codeset=None):
          """Returns the ``Translations`` instance to be used for obtaining
          translations.
  
          ``bundleId`` is the name of the bundle to use.
          ``languages`` is the list of languages to use, with subsequent ones
          being fallbacks. Additionally, based on the value of ``priority``,
          local translated values can be given precedence over Globalization
          Pipeline translated values.
  
          For example, to fallback to Spanish if French translated values are not
          found, ``languages=['fr', 'es']``. And if ``priority=gp``,
          the fallback chain will be as follows:
  
          - use ``gp`` French translated value, if not found:
          - use ``local`` French translated value, if not found:
          - use ``gp`` Spanish translated value, if not found:
          - use ``local`` Spanish translated value, if not found:
          - use source value, if not found:
          - use provided key
  
          In order to search for local translated values, the optional parameters
          must be provided according to `gettext.translation
          <https://docs.python.org/2/library/gettext.html#gettext.translation>`_
          """
  
          availableLangs = self.get_avaliable_languages(bundleId)
  
          translations = None
  
          for language in languages:
              # get local translation
              localTranslations = None
              if domain:
                  t = local_translation(domain=domain,
                      localedir=localedir, languages=[language], class_=class_,
                      fallback=True, codeset=codeset)
  
                  # only use t if it's not NullTranslations - NullTranslations
                  # indicates that a translation file was not found
                  if t is not NullTranslations:
                      localTranslations = t
  
              gpTranslations = None
  
              # get gp translation if the bundle has the language
              match = self.__get_language_match(languageCode=language,
                  languageIds=availableLangs)
              if match:
                  gpTranslations = GPTranslations(bundleId=bundleId,
                      languageId=match, client=self,
                      cacheTimeout=self.__cacheTimeout)
  
              # create the fallback chain
              if not translations:
                  # set the first translation in the chain
                  if priority == 'local':
                      if not localTranslations:
                          translations = gpTranslations
                      else:
                          translations = localTranslations
  
                          if gpTranslations:
                              translations.add_fallback(gpTranslations)
  
                  elif priority == 'gp':
                      if not gpTranslations:
                          translations = localTranslations
                      else:
                          translations = gpTranslations
  
                          if localTranslations:
                              translations.add_fallback(localTranslations)
              else:
                  # add fallback in the preferred order
                  if priority == 'local':
                      if localTranslations:
                          translations.add_fallback(localTranslations)
                      if gpTranslations:
                          translations.add_fallback(gpTranslations)
                  elif priority == 'gp':
                      if gpTranslations:
                          translations.add_fallback(gpTranslations)
                      if localTranslations:
                          translations.add_fallback(localTranslations)
  
          if not translations:
              logging.warning('No translations were found for bundleID <%s>' \
                              + ' and languages <%s> ', bundleId, languages)
              translations = NullTranslations()
  
          return translations