-
Notifications
You must be signed in to change notification settings - Fork 55
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
LocaleRegion API #3027
base: main
Are you sure you want to change the base?
LocaleRegion API #3027
Changes from 1 commit
3d650ce
e8814c1
cdf93ac
ac7843b
bb757b3
3aec1fe
a128202
2a62807
c9ba53b
856d76e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -24,23 +24,16 @@ options->put_LocaleRegion(m_webviewOption.localeRegion.c_str()); | |||||||
``` | ||||||||
|
||||||||
```c# | ||||||||
CoreWebView2Environment _webViewEnvironment; | ||||||||
WebViewCreationOptions _creationOptions; | ||||||||
public CreateWebView2Controller(IntPtr parentWindow) | ||||||||
CoreWebView2Environment environment; | ||||||||
CoreWebView2ControllerOptions CreateCoreWebView2ControllerOptions(CoreWebView2Environment environment) | ||||||||
{ | ||||||||
CoreWebView2ControllerOptions controllerOptions = new CoreWebView2ControllerOptions(); | ||||||||
controllerOptions.LocaleRegion = _creationOptions.localeRegion; | ||||||||
CoreWebView2Controller controller = null; | ||||||||
if (_creationOptions.entry == WebViewCreateEntry.CREATE_WITH_OPTION) | ||||||||
CoreWebView2ControllerOptions ControllerOptions = null; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
if (LocaleRegion != null) | ||||||||
{ | ||||||||
controller = await _webViewEnvironment.CreateCoreWebView2ControllerAsync(parentWindow, options); | ||||||||
ControllerOptions = environment.CreateCoreWebView2ControllerOptions(); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is a method needed to create the options? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ControllerOptions is an existing WebView2 class not defined in this spec. An app can have multiple instances of a webview2 environment running at once and with just a constructor we wouldn't know which instance should be creating an object and so generally creating objects is done via a CoreWebView2Environment |
||||||||
ControllerOptions.LocaleRegion = LocaleRegion; | ||||||||
} | ||||||||
else | ||||||||
{ | ||||||||
controller = await _webViewEnvironment.CreateCoreWebView2ControllerAsync(parentWindow); | ||||||||
} | ||||||||
// update locale with value | ||||||||
SetAppLocale(localeRegion); | ||||||||
return ControllerOptions; | ||||||||
} | ||||||||
``` | ||||||||
|
||||||||
|
@@ -55,14 +48,15 @@ interface ICoreWebView2StagingControllerOptions : IUnknown { | |||||||
/// 639](https://www.iso.org/iso-639-language-codes.html) and `country` is the | ||||||||
/// 2-letter code from [ISO 3166](https://www.iso.org/standard/72482.html). | ||||||||
/// | ||||||||
/// This property will update the environment creation. This is global and immutable, | ||||||||
/// so changes will not be reflected in the existing webviews. They will need to closed | ||||||||
/// and reopened in order to see the changes reflected from using the new creation environment. | ||||||||
/// This property sets the region for a CoreWebView2Environment during its creation. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this sentence. The CoreWebview2Environment already exists; indeed, it's the object that creates the CoreWebView2ControllerOptions! So this property cannot affect the CoreWebview2Environment's creation, because the creation has already happened. |
||||||||
/// Creating a new CoreWebView2Environment object that connects to an already running | ||||||||
/// browser process cannot change the region previously set by an earlier CoreWebView2Environment. | ||||||||
/// The CoreWebView2Environment and all associated webview2 objects will need to closed. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what this is saying.
|
||||||||
/// | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still confused about what the region is associated with. This text suggests that it's associated with the browser process. But if that's the case, why is it a property on the controller options? |
||||||||
/// Validation is done on the V8 engine to match on the closest locale | ||||||||
/// from the passed in locale region value. For example, passing in "en_gb" | ||||||||
/// will reflect the "en-GB" locale in V8. | ||||||||
/// If V8 cannot find any matching locale on the input value, it will default | ||||||||
/// Validation processing is done by ICU to match on the closest locale | ||||||||
/// from the passed in locale region value. ICU documentation can be found here | ||||||||
/// (https://source.chromium.org/chromium/chromium/src/+/main:third_party/icu/source/common/unicode/locid.h) | ||||||||
/// If ICU cannot find any matching locale on the input value, it will default | ||||||||
/// to the display language as the locale. | ||||||||
/// | ||||||||
/// The default value for LocaleRegion will be depend on the WebView2 language | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method name is a little misleading, since it doesn't just create the options, but sets the
LocaleRegion
as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could name it
CreateAndInitializeCoreWebView2ControllerOptions
?