-
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
adding draft for locale api review #2925
Conversation
@david-risney |
Yes. I would recommend updating the two samples in this doc (& in the sample apps) |
Thanks. Updated here and in the .idl file. |
specs/LocaleRegion.md
Outdated
* The intended value for `LocaleRegion` is in the format of `language[-country]` where `language` is the | ||
2-letter code from [ISO 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). | ||
* By default, the `LocaleRegion` will be set as the value for the Limited option in the browser. |
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.
Probably not helpful to refer to the 'Limited option in the browser' since that won't be a known thing. We can just describe this on its own terms.
specs/LocaleRegion.md
Outdated
2-letter code from [ISO 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). | ||
* By default, the `LocaleRegion` will be set as the value for the Limited option in the browser. | ||
That means that if the OS region and the display language share the same language code, |
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.
This info about the default value needs to be included in the ref docs below (the /// comments above the IDL method). Info in the ref docs doesn't need to be duplicated in the Description.
specs/LocaleRegion.md
Outdated
2-letter code from [ISO 3166](https://www.iso.org/standard/72482.html). | ||
* By default, the `LocaleRegion` will be set as the value for the Limited option in the browser. | ||
That means that if the OS region and the display language share the same language code, | ||
like 'en-GB' and 'en-US', the value will be set to the OS region. |
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.
It would be good to have a table of different options and the result. Something like the following (but with more rows) in the /// ref doc comments
OS Region | WebView2 Language | Default WebView2 LocaleRegion |
---|---|---|
en-GB | en-US | en-GB |
... | ... | ... |
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.
Got it. Will add this as part of the experimental PR
/// The Windows API `GetLocaleInfoEx` can be used if the LocaleRegion value | ||
/// is always set to match the OS region | ||
/// | ||
/// ```cpp |
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.
Instead of embedding the code directly, we generally use snippets syntax (see other APIs as examples) that will pull the snippet code out of the sample apps.
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.
Was talking to @peiche-jessica about this, if the intention is not to include some particular code in the sample app but to have it for the reference doc (like usage of GetLocaleInfoEx), then shouldn't we add it here as a comment and then it will appear as code in the reference doc only?
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.
Its better to have it at least in the reference documentation, but generally we want to copy the sample code out of the sample app so end devs can easily try out the code or search and find the code on github. Why don't we want to include this sample code in the sample app?
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.
Also it would be nice to complete these samples to show how you would actually use them with the property.
specs/LocaleRegion.md
Outdated
interface ICoreWebView2StagingControllerOptions : IUnknown { | ||
/// Interface for locale region that is updated through the ControllerOptions | ||
/// API. | ||
/// The default region for WebView. It applies to browser UI such as |
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.
Does it actually apply to browser UI? I thought it was only specific JavaScript APIs? Speaking of which, you should explicitly list the exact JavaScript APIs that are affected.
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.
Yeah I might have been too general here. It affects the Intl.DateTimeFormat() Locale object which gets reflected in the UI for time/dates/other string formatting if it's used.
specs/LocaleRegion.md
Outdated
/// If V8 cannot find any matching locale on the input value, it will default | ||
/// to the display language as the locale. | ||
/// | ||
/// The Windows API `GetLocaleInfoEx` can be used if the LocaleRegion value |
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.
I would rephrase to make this more OS independent like "Use OS specific APIs to determine the OS region to use with this property if you want to match the OS. For example in Windows you can use the GetLocaleInfoEx
method."
Also, can we recommend the methods to use for .NET and WinRT? .NET is likely our most popular language.
specs/LocaleRegion.md
Outdated
// MSOWNERS: [email protected] | ||
[propget] HRESULT LocaleRegion([out, retval] LPWSTR* locale); | ||
|
||
/// Sets the `Region` property. |
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.
/// Sets the `Region` property. | |
/// Sets the `LocaleRegion` property. | |
specs/LocaleRegion.md
Outdated
```cpp | ||
[uuid(0c9a374f-20c3-4e3c-a640-67b78a7e0a48), object, pointer_default(unique)] | ||
interface ICoreWebView2StagingControllerOptions : IUnknown { | ||
/// Interface for locale region that is updated through the ControllerOptions |
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.
This first sentence isn't really necessary - should be sort of implied by the ref doc which will include links, the name of the interface and so on.
specs/LocaleRegion.md
Outdated
interface ICoreWebView2StagingControllerOptions : IUnknown { | ||
/// Interface for locale region that is updated through the ControllerOptions | ||
/// API. | ||
/// The default region for WebView. It applies to browser UI such as |
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.
/// The default region for WebView. It applies to browser UI such as | |
/// The default region for the WebView2. It applies to browser UI such as | |
/// The Windows API `GetLocaleInfoEx` can be used if the LocaleRegion value | ||
/// is always set to match the OS region | ||
/// | ||
/// ```cpp |
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.
Its better to have it at least in the reference documentation, but generally we want to copy the sample code out of the sample app so end devs can easily try out the code or search and find the code on github. Why don't we want to include this sample code in the sample app?
specs/LocaleRegion.md
Outdated
/// 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. | ||
/// | ||
/// Validation is done on the V8 engine to match on the closest locale |
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.
Saying that the V8 engine is doing this isn't helpful unless how the V8 engine does it is well known or well documented. Otherwise you can just talk in terms of this API and how validation of the parameter is performed.
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.
I spoke to the owner of the browser side and they said they think the validation processing is done by ICU. And linked me this to reference some documentation here: https://source.chromium.org/chromium/chromium/src/+/main:third_party/icu/source/common/unicode/locid.h
Is it okay to not mention the specific examples and just link to this? looking through the link, there's no concrete explanation of the matchign logic
specs/LocaleRegion.md
Outdated
/// and reopened in order to see the changes reflected from using the new creation environment. | ||
/// | ||
/// 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" |
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.
This paragraph does not make it clear what is actually allowed or what validation is actually performed. It sounds like '_' is allowed instead of '-'? Are there many other things like that? Or is the _ syntax a different form language/country code format that we also accept and need to document? Is this the same as the syntax and validation performed for the Language property?
specs/LocaleRegion.md
Outdated
/// 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, |
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.
nit: Just wording suggestions
/// This property will update the environment creation. This is global and immutable, | |
/// This property sets the region for a CoreWebView2Environment during its creation. |
specs/LocaleRegion.md
Outdated
/// 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 |
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.
Instead of global let's say that it applies to the environment and cannot be changed for that environment. (An app could have more than one environment so the property isn't global in that sense)
/// so changes will not be reflected in the existing webviews. They will need to closed | |
/// 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 | |
/// The Windows API `GetLocaleInfoEx` can be used if the LocaleRegion value | ||
/// is always set to match the OS region | ||
/// | ||
/// ```cpp |
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.
Also it would be nice to complete these samples to show how you would actually use them with the property.
2-letter code from [ISO 3166](https://www.iso.org/standard/72482.html). | ||
|
||
# Examples | ||
```cpp |
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.
The two examples in C++ & C# should do the same thing. Here the C++ just sets up the controller options, and the C# one also calls create async, and setapplocale
@david-risney created a PR to include an option to use OSRegion for the LocaleRegion value in the SampleApp. Because it's now part of the code snippet, do I still need to include the examples in the comments for c++ and c#? |
No description provided.