How to change language?

2,118 views
Skip to first unread message

Eliozzzzzz

unread,
Jan 15, 2014, 6:28:08 AM1/15/14
to cefs...@googlegroups.com
Hello everybody,
i tried to change en-US locale to it-IT but nothing happens: the browser display dates and numbers in en-US format. This is my code:

 ///CEF settings 
 Settings csettings = new CefSharp.Settings();
 //csettings.PackLoadingDisabled = true;
 csettings.LocalesDirPath = Application.StartupPath + "\\locales";
 //csettings.Locale = "it-IT";
 csettings.Locale = "it";
 do { CefSharp.CEF.Initialize(csettings); } while (!CefSharp.CEF.IsInitialized);

 ///Browser settings
 BrowserSettings bsettings = new BrowserSettings();
 bsettings.EncodingDetectorEnabled = true;

///Init browser
//_webBrowser = new WebView();
_webBrowser = new WebView(string.Empty, bsettings);
_webBrowser.Dock = DockStyle.Fill;
_webBrowser.MenuHandler = this;
_webBrowser.RequestHandler = this;
_webBrowser.CreateControl();
this.Controls.Add(_webBrowser);

 ///Loadurl
 _webBrowser.PropertyChanged += new PropertyChangedEventHandler((sender, e) =>
 {
         if (e.PropertyName == "IsBrowserInitialized" && _webBrowser.IsBrowserInitialized)
         {
                 _webBrowser.Load(url);
         }
 });

Anyone can hekp me to change the default locale?
Thanks.
 

Eliozzzzzz

unread,
Jan 15, 2014, 7:58:05 AM1/15/14
to cefs...@googlegroups.com
I found the solution: you need to set request headers, not to set locale property!!! :)

 bool IRequestHandler.OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)
        {
            //string txt = "";
            //foreach (KeyValuePair<string, string> header in requestResponse.Request.GetHeaders())
            //{
            //   txt += header.ToString()+"\n";
            //}
            //Dbg.Print(txt);
 
            ///Verifica che la url contenga una delle azioni specificate
            //if (_actions.Any(requestResponse.Request.Url.Contains))
            //{
            //    ///Progress
            //    Dlg.ShowProgress(_max, _step, "Caricamento in corso...");
            //}
 
            Dictionary<stringstring> headers = new Dictionary<stringstring>();
            headers.Add("Accept-Language""it-IT");
            requestResponse.Request.SetHeaders(headers);
 
            return false;
        }

It works fine.

-----------------------------------------------------------------

Joe Behymer

unread,
May 3, 2015, 1:28:51 PM5/3/15
to cefs...@googlegroups.com
Hey Eliozzzzzz, just wanted to say thanks for following up with a solution a year and a half ago.  It majorly helped me today.  Cheers from around the world!

Eliozzzzzz

unread,
May 3, 2015, 1:45:39 PM5/3/15
to cefs...@googlegroups.com


Il giorno domenica 3 maggio 2015 19:28:51 UTC+2, Joe Behymer ha scritto:
Hey Eliozzzzzz, just wanted to say thanks for following up with a solution a year and a half ago.  It majorly helped me today.  Cheers from around the world!

thanks, i'm happy for help you
cheeers

Qifan Xi

unread,
May 14, 2015, 7:15:45 PM5/14/15
to cefs...@googlegroups.com
This might sound like a strange coincidence, but I had to use your solution today as well.

Elios Panai

unread,
May 15, 2015, 2:16:56 AM5/15/15
to cefs...@googlegroups.com
wow what a strange coincidence! :)

--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/Klvi9TOObX4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/d/optout.

Bill Tutt

unread,
May 19, 2015, 3:04:08 PM5/19/15
to cefs...@googlegroups.com
I'm glad the work around works, but did anyone try to discover why CEF isn't supplying the header when the locale is set?
i.e. what happens when you use cefclient, etc...

Bill

Elios Panai

unread,
May 20, 2015, 7:03:42 AM5/20/15
to cefs...@googlegroups.com
I don't know why... maybe it's fixed in the last release...
Reply all
Reply to author
Forward
0 new messages