次の方法で共有


CoreWebView2ControllerOptions.ScriptLocale Property

Definition

Manages the value of the controller's script locale.

public string ScriptLocale { get; set; }
member this.ScriptLocale : string with get, set
Public Property ScriptLocale As String

Property Value

Remarks

The ScriptLocale property is to specify the default script locale. 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.The intended locale value is in the format of BCP 47 Language Tags. More information can be found from [IETF BCP47](https://www.ietf.org/rfc/bcp/bcp47.html ). The default value for ScriptLocale will be 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 RegionWebView2 LanguageDefault WebView2 ScriptLocale
en-GBen-USen-GB
es-MXen-USen-US
en-USen-GBen-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 always want to match with the OS region. For example:
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
return cultureInfo.Name

Applies to