Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Incorrect Languange Rendering

Post Reply
rgdawson
Posts: 22
Joined: Tue Apr 10, 2018 11:05 pm

Incorrect Languange Rendering

Post by rgdawson »

I have an issue with recent versions of CEF/CEF4Delphi and I am struggling to describe it, but here goes. I am using CEF4Delphi in an app that embeds CEF in order to browse a local network server running Logitech Media Server. Logitech Media Server allows the user to select the desired language. Recently, CEF/CEF4Delphi does not render json requests in the selected language. It works correctly in any browser (Edge, Chrome, etc) and it works in older versions of CEF/CEF4Delphi. But now, with recent versions of CEF it is not rendering the correct language. I have attached an image to show what I mean. On the left, it is correct (I have selected German in this example). The left hand image was created using CEF4Delphi 75.0.3770.100. On the right is the most recent version of CEF4Delphi. The rows that are failing to render in German are the result of the browser retrieving the information from the server using Javascript and Json rpc. Something may be wrong in the handling of the language headers of those requests, I'm not sure. I didn't write the server code. I am not doing anything my pascal/delphi code. I'm sorry I cannot be more precise. A user reported it and we don't know when it started happening. I just know when I rolled back to 75.0.3770.100 it worked again (I can't roll back to any other intermediate versions.)

Any ideas?

R Greg Dawson
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 4043
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Incorrect Languange Rendering

Post by salvadordf »

I'm sorry but I don't know the "Logitech Media Server" and I don't know what could be causing this issue.

However, I can tell you that some JavaScript requests features can only be changed at initialization. For example, you can set a custom user agent before CEF is initialized and then set a different one intercepting the request headers in the TChromium.OnBeforeResourceLoad event but JavaScript requests are independent and they keep using the user agent set at initialization.

Perhaps the "Logitech Media Server" uses the HTTP "Accept-Language" request header to send the text items with the right language. If that's the case, there are several ways to set the language :
  • Before the GlobalCEFApp.StartMainProcess call with GlobalCEFApp.AcceptLanguageList
  • Before the TChromium.CreateBrowser call with TChromium.Options.AcceptLanguageList
  • Modifying the HTTP headers in the TChromium.OnBeforeResourceLoad event but this event is NOT used by JavaScript requests.


Please test the "Logitech Media Server" with the same Chrome or Chromium version as the one used by CEF to see if it's a Chrome issue.

Also test the "Logitech Media Server" with the official CEF "Sample Application" to see if it's a CEF issue :
http://opensource.spotify.com/cefbuilds ... nt.tar.bz2
User avatar
salvadordf
Posts: 4043
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Incorrect Languange Rendering

Post by salvadordf »

I forgot that you can also try setting the "intl.accept_languages" preference to change the "Accept-Language" header after the browser has been created but I'm not sure this will work.

Is your application using a cache directory with the GlobalCEFApp.cache property ?
Has the the application write privileges in the cache directory ?
User avatar
salvadordf
Posts: 4043
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Incorrect Languange Rendering

Post by salvadordf »

I just uploaded a new CEF4Delphi version that includes the TChromium.AcceptLanguageList property that can be updated after the TChromium.CreateBrowser call.

That property updates the browser preferences and you need to refresh the page to see the results in google.com
rgdawson
Posts: 22
Joined: Tue Apr 10, 2018 11:05 pm

Re: Incorrect Languange Rendering

Post by rgdawson »

The new version of CEF4Delphi you just uploaded seems to fix the problem. I made no changes to my code, just recompiled with the latest you uploaded and problem is gone. Thanks much!

R Greg Dawson
rgdawson
Posts: 22
Joined: Tue Apr 10, 2018 11:05 pm

Re: Incorrect Languange Rendering

Post by rgdawson »

Oops, no, in my rush before work, I must have gotten confused. No change, not working. I'll dig into this when I get home tonight.

R Greg Dawson
rgdawson
Posts: 22
Joined: Tue Apr 10, 2018 11:05 pm

Re: Incorrect Languange Rendering

Post by rgdawson »

The SimpleBrowser Demo works correctly, so this must be something I am doing different. Not sure why my app works fine with older CEF and not newer, but since it works with demo, I'm going to assume this is my problem for now.

R Greg Dawson
rgdawson
Posts: 22
Joined: Tue Apr 10, 2018 11:05 pm

Re: Incorrect Languange Rendering

Post by rgdawson »

Another data point, the MiniBrowser demo does not work, it exhibits the same problem, still trying to figure out why.

R Greg Dawson
Post Reply