New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to set Language on WPF WebView2 when using PRISM #1162
Comments
Hey Ingrid - What is the behavior you are hoping to achieve by setting Language property on WebView2? Currently I don't think we are handling the WPF FrameworkElement.Language property in the WebView2 control, but we do have an option in CoreWebView2EnvironmentOptions.Language. However that requires creating a new environment, and creating a new WebView2 control using that language. I don't there's currently a way to do this on the fly. |
Hello @champnic For example, I display the bing.com url on my WebView2 control which was initialized with the fr-FR language (as you said, by creating CoreWebView2EnvironmentOptions with Language property to "fr-FR". Bing displays all text in french. OK. The user change its current language (feature available on our product) and swith to English. I am able to get this event (culture changed), but event if I recreate the CoreWebView2EnvironmentOptions with the new culture (en-US), and if I call the Reload() method available on WebView2, the Bing page is still in french. Thanks. |
Instead of reload, you need to close the current WebView2, create a new environment using those environment options |
Hello, I probably have the same issue. On a fresh execution, I set the language to FR in the code, I open the WebView, I press F12 and I type in the console "navigator.language", I have "fr", it's normal. I close the debug. I have the latest version of WebView2. Any idea? |
That's interesting. I have "en-us" by default on my machine. When I set Language to "fr-fr" I see french UI in the DevTools, but indeed the |
I have noticed this as well. |
I am also encountering the same issue using |
i found that the language specified with the very first creation of the environment is accepted. clear your UDF and with the next environment your setting will take effect. |
@champnic I see this issue has been tracked as a bug for about a year now. Can you set our expectations regarding when we might see a fix? Our product runs in many cultures. So, getting the language right is important to our customers. Please let us know. Thanks! |
This bug in particular is low priority on our backlog, so probably no fix for a while. Just want to make sure you are aware of the language options currently available though (also described earlier in this thread): |
Thanks for the quick reply, @champnic ! My understanding of this issue is that setting CoreWebView2EnvironmentOptions.Language does not affect the Accept-Language header sent by WebView2. Have I misunderstood? |
It will affect the Accept-Language as well. Though there does seem to be an issue if you are changing the language after the User Data Folder has already been created. @pwsimon mentions that there may be a way to selectively clear that information from the UDF. Or you can probably handle the WebResourceRequested event and change the request headers as a workaround in the meantime. |
We confirmed that we're running into the issue:
If we start with an empty/missing UDF, we see |
I use an event to override accept-language header. See #833 (comment) |
Hello,
We use WebView2 in one of our WPF project. In this project, we use PRISM to manage navigation, view caching, events...
We also have an event triggered when a user change his current language.
But when this event is fired, I try to implement the change of the Language on the WebView2 but it isn't applied (the property Language of the component iw updated but event after a refresh on the component, webpage stay on the previous language. I have to restart my application in order to use the correct language.
With others WPF components, event if they are cached with PRISM mechanism, if we change the Language property, it is applied on the fly.
Is there a way to update immediatly the Language in my case ?
Thanks for you reply.
Ingrid
AB#34784444
The text was updated successfully, but these errors were encountered: