addons14/base_rest/http.py
def _determine_context_lang(self):
        """
        In this function, we parse the preferred languages specified into the
        'Accept-language' http header. The lang into the context is initialized
        according to the priority of languages into the headers and those
        available into Odoo.
        """
        accepted_langs = self.httprequest.headers.get("Accept-language")
        if not accepted_langs:
            return
        parsed_accepted_langs = parse_accept_language(accepted_langs)
        installed_locale_langs = set()
        installed_locale_by_lang = defaultdict(list)
        for lang_code, _name in self.env["res.lang"].get_installed():
            installed_locale_langs.add(lang_code)
            installed_locale_by_lang[lang_code.split("_")[0]].append(lang_code)

        # parsed_acccepted_langs is sorted by priority (higher first)
        for lang in parsed_accepted_langs:
            # we first check if a locale (en_GB) is available into the list of
            # available locales into Odoo
            locale = None
            if lang.locale in installed_locale_langs:
                locale = lang.locale
            # if no locale language is installed, we look for an available
            # locale for the given language (en). We return the first one
            # found for this language.
            else:
                locales = installed_locale_by_lang.get(lang.language)
                if locales:
                    locale = locales[0]
            if locale:
                # reset the context to put our new lang.
                context = dict(self._context)
                context["lang"] = locale
                # the setter defiend in odoo.http.WebRequest reset the env
                # when setting a new context
                self.context = context
                break

        In this function, we parse the preferred languages specified into the
        'Accept-language' http header. The lang into the context is initialized
        according to the priority of languages into the headers and those
        available into Odoo.
        
In this function, we parse the preferred languages specified into the
'Accept-language' http header. The lang into the context is initialized
according to the priority of languages into the headers and those
available into Odoo.
In this function we parse the preferred languages specified into the ' Accept - language ' http header . The lang into the context is initialized according to the priority of languages into the headers and those available into Odoo .
def _determine_context_lang(self):
        accepted_langs = self.httprequest.headers.get("Accept-language")
        if not accepted_langs:
            return
        parsed_accepted_langs = parse_accept_language(accepted_langs)
        installed_locale_langs = set()
        installed_locale_by_lang = defaultdict(list)
        for lang_code, _name in self.env["res.lang"].get_installed():
            installed_locale_langs.add(lang_code)
            installed_locale_by_lang[lang_code.split("_")[0]].append(lang_code)
        for lang in parsed_accepted_langs:
            locale = None
            if lang.locale in installed_locale_langs:
                locale = lang.locale
            else:
                locales = installed_locale_by_lang.get(lang.language)
                if locales:
                    locale = locales[0]
            if locale:
                context = dict(self._context)
                context["lang"] = locale
                self.context = context
                break
def _determine_context_lang ( self ) : accepted_langs = self . httprequest . headers . get ( "Accept-language" ) if not accepted_langs : return parsed_accepted_langs = parse_accept_language ( accepted_langs ) installed_locale_langs = set ( ) installed_locale_by_lang = defaultdict ( list ) for lang_code , _name in self . env [ "res.lang" ] . get_installed ( ) : installed_locale_langs . add ( lang_code ) installed_locale_by_lang [ lang_code . split ( "_" ) [ 0 ] ] . append ( lang_code ) for lang in parsed_accepted_langs : locale = None if lang . locale in installed_locale_langs : locale = lang . locale else : locales = installed_locale_by_lang . get ( lang . language ) if locales : locale = locales [ 0 ] if locale : context = dict ( self . _context ) context [ "lang" ] = locale self . context = context break
In this function, we parse the preferred languages specified into the
'Accept-language' http header.
In this function we parse the preferred languages specified into the ' Accept - language ' http header .
"""
        In this function, we parse the preferred languages specified into the
        'Accept-language' http header. The lang into the context is initialized
        according to the priority of languages into the headers and those
        available into Odoo.
        """ # parsed_acccepted_langs is sorted by priority (higher first) # we first check if a locale (en_GB) is available into the list of # available locales into Odoo # if no locale language is installed, we look for an available # locale for the given language (en). We return the first one # found for this language. # reset the context to put our new lang. # the setter defiend in odoo.http.WebRequest reset the env # when setting a new context
self