The IWebView.LoadUrl(url, headers) method allows you to load a URL with specific request headers. However, Chromium doesn't allow the Accept-Language HTTP header to be overridden on a per-request basis. So, if you want to change the Accept-Language header with 3D WebView for Windows and macOS, you must instead use StandaloneWebView.SetCommandLineArguments() to passing the --lang
argument to Chromium at the start of the app, like this:
void Awake() {
// Call this at the start of the app, before webviews are initialized.
// Replace "es" (the language code for Spanish) with
// the language code for your specific target language.
StandaloneWebView.SetCommandLineArguments("--lang=es");
}
After that, the specified language will be used for the browser's Accept-Language request header and for the navigator.language JavaScript API. Some websites implement localization by serving a different version of the site based on the Accept-Language request header. However, many websites only support one language and ignore the Accept-Language header. 3D WebView for Windows and macOS doesn't include built-in language translation because that is a proprietary feature of Google Chrome that is not part of the open source Chromium browser engine.