Comments (13)
@zbraniecki Oh thanks for explaining, my mistake. Agree that baseName
sounds better then.
from proposal-intl-locale.
What do we do with -t- section? There is only value, no key (as in it-t-ja)
What happens with -x- key-values? Esp. if they match names in -u-?
The way we decided to approach it is that we will preserve the -t-
and -x-
but you can't retrieve or set them via the options.
So:
let loc = new Intl.Locale("sr-Cyrl-u-hc-h24-x-foo", {
calendar: "gregory"
});
loc.calendar; // "gregory"
loc.locale; // "sr-Cyrl"
loc.hourCycle; // "h24"
loc.toString(); // "sr-Cyrl-u-ca-gregory-hc-h24-x-foo"
Wrt. the second:
let loc = new Intl.Locale("sr-u-ca-buddhist", {
calendar: 'gregory'
});
console.log(loc.locale); // "sr"
console.log(loc.calendar); // "gregory" - options override lang tag
console.log(loc.toString()); // "sr-u-ca-gregory"
Does it seem reasonable to you?
from proposal-intl-locale.
Hmm, also, IIRC we don't have a locale
getter. We have language
, script
, region
.
I'm not sure if Locale.prototype.locale
makes sense as a name, especially if it strips extension keys, but I understand the value of a getter that returns just language/script/region/variants without extension keys. That would be a new addition to the spec tho.
from proposal-intl-locale.
@zbraniecki I am somewhat confused then.
Is loc.locale just a language tag then (sr, no script or region)? Or is loc.locale equivalent of getBaseName in ICU (language, script and region)?
I see it represents both in your example.
To clarify:
let loc = new Intl.Locale('sr-Cyrl-RS-u-hc-h24');
loc.locale; // sr-Cyrl-RS or sr?
loc.region; // RS or does this getter exist?
from proposal-intl-locale.
@nciric - my examples above are just filled-in copies of your examples.
In the proposal, we have a field language
which is sr
, and we do not have a field locale
.
from proposal-intl-locale.
@zbraniecki I actually copied them from main proposal page, where locale exists. Maybe we need to fix that:
let loc = new Intl.Locale("pl-u-hc-h12", {
calendar: 'gregory'
});
console.log(loc.locale); // "pl"
console.log(loc.hourCycle); // "h12"
console.log(loc.calendar); // "gregory"
console.log(loc.toString()); // "pl-u-ca-gregory-hc-h12"
But, ok, locale is actually toString in our case. For v2 we may need baseName property, which is locale without extensions.
from proposal-intl-locale.
I actually copied them from main proposal page, where locale exists. Maybe we need to fix that:
Definitely! It should be language
:)
For v2 we may need baseName property, which is locale without extensions.
+1
from proposal-intl-locale.
The lack of a locale
getter (which would omit extension keys) is an accidental omission. I was picturing that we would have it, and presented slide decks to the committee including it. The name locale
rather than baseName
might be better because it is parallel to resolvedOptions
, which is a general design goal here. I'm thinking we should make a patch for this now.
For transforms, I share @zbraniecki's understanding in #22 (comment) . Do you have any concerns about whether the specification text does this?
from proposal-intl-locale.
Apologies, much of the logic here was in a PR that I forgot to merge until now. #21
from proposal-intl-locale.
@littledan locale sounds fine. It would be defined as base name of input locale, without extensions, after canonicalization.
from proposal-intl-locale.
I think I prefer Locale.baseName
over Locale.locale
because that means that locale
term has two meanings - as a class/API it contains extensions, and as a property/getter it specifically means the Locale without extensions
.
from proposal-intl-locale.
@zbraniecki What do you think about the usage of locale
in resolvedOptions
which we will not be able to change?
from proposal-intl-locale.
@littledan locale
in ResolvedOptions is exactly the same as Locale.prototype.toString()
:
(new Intl.DateTimeFormat("en-US-u-ca-gregory")).resolvedOptions().locale; // "en-US-u-ca-gregory
What @nciric suggested is (new Locale("en-US-u-ca-gregory")).locale; // "en-US"
I believe which would be inconsistent
from proposal-intl-locale.
Related Issues (20)
- Modified CanonicalizeLocaleList does not accept Intl.Locale instances when provided as the only argument HOT 1
- Using Unicode locale ID vs BCP 47 in our spec HOT 51
- Resolved value for Unicode extension values when "true" is removed? HOT 4
- Simplified the change to 2.1 CanonicalizeLocaleList HOT 3
- Docs(MDN) Documentation for Intl.Locale HOT 17
- Does hourCycle exist unconditionally? HOT 3
- Not all RFC 5646 production names updated HOT 3
- Move "get caseFirst" after "get calendar"
- Update references to match current UTS 35 spec HOT 11
- Use `type` production from UTS35
- Directly use unicode_language_id in "get baseName"
- Need to test for SameValue(r.[[kn]], "") in addition to SameValue(r.[[kn]], "true")
- no validation of value of extensions in tag? HOT 8
- CanonicalizeLanguageTag should remove duplicate attributes/keywords in a Unicode extension, consistent with Intl.Locale HOT 6
- Getting the default locale HOT 10
- Drop this proposal in favor of a more general user settings object HOT 6
- Spec is vague regarding internal data structure representation HOT 12
- Canonicalise Unicode extensions options added through ResolveLocale HOT 8
- CanonicalizeUnicodeLocaleId should only perform step 1 of "BCP 47 Language Tag to Unicode BCP 47 Locale Identifier" HOT 3
- Archive repository, redirect draft to ecma402 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-intl-locale.