Accept-Language does not work

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Accept-Language does not work

Postby sandmeteor » Fri Mar 20, 2020 3:36 pm

Hi,
Does anyone can confirm that settings Accept-Language work in one of the latest version of CEF?
After update from cef 75 to 79 and 80 it stopped working. I did not changed my codes.

Code: Select all
cef_return_value_t CefHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefRequestCallback> callback)
{
  CefRequest::HeaderMap hdrMap;
  request->GetHeaderMap(hdrMap);
 
  hdrMap.insert(std::make_pair("Accept-Language", _params.language.toUtf8()));
 
  request->SetHeaderMap(hdrMap);

  return RV_CONTINUE;
}

I can set any custom headers but can not change Accept-Language.
sandmeteor
Techie
 
Posts: 17
Joined: Sat Jun 22, 2019 4:25 pm

Re: Accept-Language does not work

Postby ndesktop » Mon Oct 05, 2020 2:21 am

Works for me in 4147.
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am

Re: Accept-Language does not work

Postby amaitland » Mon Oct 05, 2020 3:31 am

Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: Accept-Language does not work

Postby ssaraf » Mon Nov 09, 2020 4:42 am

I tried the solution provided here https://bitbucket.org/chromiumembedded/ ... ault-en-us

Setting the accept-language-list using cefsettings like
(&m_cefSettings.accept_language_list).FromWString(L"en-US, ja"); passing all the languages supported by the app overrides the header like
accept.PNG
accept.PNG (18.88 KiB) Viewed 6707 times


which is different from how it was before the commit (https://bitbucket.org/chromiumembedded/ ... e6f9332e87) in version 3904 like
a1.PNG
a1.PNG (11.51 KiB) Viewed 6707 times


Are applications supposed to be setting this header value using accept-language-list to any other value other than english when it is overridden from the application?

Is the Accept-Language header supposed to be set by the browser based on whatever your system language is set to?

Is there something I am missing out to override the header value?
ssaraf
Techie
 
Posts: 31
Joined: Mon Nov 09, 2020 2:18 am

Re: Accept-Language does not work

Postby magreenblatt » Mon Nov 09, 2020 12:21 pm

@ssaraf The behavior in the first image looks correct. You can set CefSettings.accept_language_list if you want to override the default en-US.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Accept-Language does not work

Postby ssaraf » Mon Mar 04, 2024 6:51 am

If we use CefSettings.accept_language_list in the latest versions we see half app rendered in the language set and half in the default en-US language. How can we set using language::prefs::kSelectedLanguages ?
ssaraf
Techie
 
Posts: 31
Joined: Mon Nov 09, 2020 2:18 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 27 guests