Esempio n. 1
0
File: wsgi.py Progetto: tdp100/nova
    def best_match_language(self):
        """Determine the best available language for the request.

        :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
        return self.accept_language.best_match(i18n.get_available_languages())
Esempio n. 2
0
    def best_match_language(self):
        """Determine the best available language for the request.

        :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
        return self.accept_language.best_match(i18n.get_available_languages())
    def best_match_language(self):
        """Determine the best available language for the request.

        :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

        # NOTE(takashin): To decide the default behavior, 'default' is
        # preferred over 'default_tag' because that is return as it is when
        # no match. This is also little tricky that 'default' value cannot be
        # None. At least one of default_tag or default must be supplied as
        # an argument to the method, to define the defaulting behavior.
        # So passing a sentinal value to return None from this function.
        best_match = self.accept_language.lookup(
            i18n.get_available_languages(), default='fake_LANG')

        if best_match == 'fake_LANG':
            best_match = None
        return best_match
Esempio n. 4
0
    def best_match_language(self):
        """Determine the best available language for the request.

        :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

        # NOTE(takashin): To decide the default behavior, 'default' is
        # preferred over 'default_tag' because that is return as it is when
        # no match. This is also little tricky that 'default' value cannot be
        # None. At least one of default_tag or default must be supplied as
        # an argument to the method, to define the defaulting behavior.
        # So passing a sentinal value to return None from this function.
        best_match = self.accept_language.lookup(
            i18n.get_available_languages(), default='fake_LANG')

        if best_match == 'fake_LANG':
            best_match = None
        return best_match