The OpenD Programming Language

ICoreWebView2ControllerOptions2.get_ScriptLocale

The default locale for the WebView2. It sets the default locale for all Intl JavaScript APIs and other JavaScript APIs that depend on it, namely Intl.DateTimeFormat() which affects string formatting like in the time/date formats. Example: Intl.DateTimeFormat().format(new Date()) The intended locale value is in the format of BCP 47 Language Tags. More information can be found from IETF BCP47.

This property sets the locale for a CoreWebView2Environment used to create the WebView2ControllerOptions object, which is passed as a parameter in CreateCoreWebView2ControllerWithOptions.

Changes to the ScriptLocale property apply to renderer processes created after the change. Any existing renderer processes will continue to use the previous ScriptLocale value. To ensure changes are applied to all renderer process, close and restart the CoreWebView2Environment and all associated WebView2 objects.

The default value for ScriptLocale will depend on the WebView2 language and OS region. If the language portions of the WebView2 language and OS region match, then it will use the OS region. Otherwise, it will use the WebView2 language.

| OS Region | WebView2 Language | Default WebView2 ScriptLocale | |-----------|-------------------|-------------------------------| | en-GB | en-US | en-GB | | es-MX | en-US | en-US | | en-US | en-GB | en-US |

You can set the ScriptLocale to the empty string to get the default ScriptLocale value.

Use OS specific APIs to determine the OS region to use with this property if you want to match the OS. For example:

Win32 C++:

wchar_t osLocale[LOCALE_NAME_MAX_LENGTH] = {0};
GetUserDefaultLocaleName(osLocale, LOCALE_NAME_MAX_LENGTH);

The caller must free the returned string with CoTaskMemFree. See API Conventions. \snippet AppWindow.cpp ScriptLocaleSetting

interface ICoreWebView2ControllerOptions2
@" propget"
HRESULT
get_ScriptLocale
(
LPWSTR* locale
)

Meta