Changing default browser language

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.

Changing default browser language

Postby callum » Mon Jun 01, 2015 4:16 pm

I would like to be able to change the default language of my embedded browser.

I am adding an entry to the CefSettings variable I pass to CefInit with something like:

Code: Select all
std::string locale("zh_CN");
cef_string_utf8_to_utf16(locale.c_str(), locale.size(), &settings.locale);


but when I navigate to http://google.com I still see Google in English. Is this what you would expect after changing the locale and is there an additional/different setting I need to change to alter the default browser language?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Changing default browser language

Postby magreenblatt » Mon Jun 01, 2015 4:37 pm

callum wrote:std::string locale("zh_CN");

The value should be "zh-CN". You should then see Chinese in the right-click context menu and the executing `navigator.language` in the DevTools console will show the same value.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Changing default browser language

Postby callum » Mon Jun 01, 2015 5:12 pm

Thanks - I don't have right-click or dev-tools hooked up yet but displaying the value with some JavaScript (http://jsfiddle.net/cajeamx9/) appears to be doing the right thing.

Google.com still appears in English though - is there a setting to change the default language vs the locale?

The equivalent of adding a new language in Chrome settings I guess.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Changing default browser language

Postby magreenblatt » Mon Jun 01, 2015 5:25 pm

callum wrote:Google.com still appears in English though - is there a setting to change the default language vs the locale?

Newer CEF versions support CefSettings.accept_language_list which can be used to configure the Accept-Language HTTP header value.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Changing default browser language

Postby callum » Mon Jun 01, 2015 5:38 pm

Understood - doesn't appear to be in the version I'm using right now (branch 2272) but I see the issue here (https://code.google.com/p/chromiumembedded/source/detail?spec=svn2033&r=2033) so I should be able to figure out which branch I need.

Thank you.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Changing default browser language

Postby callum » Thu Jul 16, 2015 3:50 pm

Just to close the loop on this, I moved to revision 2357 and modified CefSettings::accept_language_list instead of CefSettings::locale and things worked as I expected - e.g. Using zh-CN makes http://google.com render in Chinese.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Changing default browser language

Postby ysaliens » Mon Oct 02, 2017 1:56 pm

Could you post the code to do this? Were you ever able to make it so CEF would use the OS language automatically for locale AND render?
ysaliens
Techie
 
Posts: 20
Joined: Mon Oct 02, 2017 1:08 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 47 guests