Beispiel #1
0
    def best_match_language(self):
        """Determines best available locale from the Accept-Language header.

        :returns: the best language match or None if the 'Accept-Language'
                  header was not available in the request.
        """
        if not self.accept_language:
            return None
        langs = i18n.get_available_languages('glance')
        return self.accept_language.best_match(langs)
Beispiel #2
0
    def best_match_language(self):
        """Determines best available locale from the Accept-Language header.

        :returns: the best language match or None if the 'Accept-Language'
                  header was not available in the request.
        """
        if not self.accept_language:
            return None
        langs = i18n.get_available_languages('glance')
        return self.accept_language.best_match(langs)
Beispiel #3
0
    def best_match_language(self):
        """Determines best available locale from the Accept-Language header.

        :returns: the best language match or None if the 'Accept-Language'
                  header was not available in the request.
        """
        if not self.accept_language:
            return None
        langs = i18n.get_available_languages('glance')
        # NOTE(rosmaita): give the webob lookup() function a sentinal value
        # for default so we can preserve the behavior of this function as
        # indicated by the current unit tests.  See Launchpad bug #1765748.
        best_match = self.accept_language.lookup(langs, default='fake_LANG')
        if best_match == 'fake_LANG':
            best_match = None
        return best_match