-
Notifications
You must be signed in to change notification settings - Fork 106
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
Locale related APIs -- language matching #46
Comments
Two things:
|
sure! thanks for the feedback :) |
@caridy - I started playing with Intl.js and ended up separating Branch is here: https://github.com/zbraniecki/Intl.js/tree/locale I also wrote a simple polyfill just for Let's now talk about the API and get it agreed upon (before I start the daunting task of working on the spec) |
@zbraniecki I added the module system into Intl.js to be able to split it into small chunks, I didn't get to split core into small chunks. In other words, go for it, we will appreciate it. Just open a PR there, and we can discuss the details. In the other hand, I'm more interested on the API discussion :) |
@caridy Cool. Do you have any comments on the API I proposed in comment 1? I'd like to make Locale a good unified language negotiation API for other Intl APIs and localization frameworks. I believe that with those five functions are enough to achieve that. On top of that, all of that code except of |
I guess it's not the right idea to at the same time refactor a major piece of code and introduce new feature for debate in it :) So I updated my @caridy - does it look like something you may be interested in? |
update: we need to cook the proposal for the next meeting in two weeks. will try to coordinate some time to work on this. |
We've talked about this with @caridy and he mentioned that Intl formatters may be interested in switching to something like This would mean that we don't have to expose The only thing coming to my mind that we may want to use That would leave us with:
(and later)
wrt. prioritizeLocales you can see an implementation here: https://github.com/l20n/l20n.js/blob/v1.0.x/lib/l20n/intl.js#L434 It uses |
I'm interested to know the exact algorithm and how this relates to https://github.com/rxaviers/ecma402-fix-lookup-matcher please. |
@rxaviers that's precisely the reason why we will abstract the operation to produce the parent list, then we can update that to take into consideration the proper algo step. |
@rxaviers Ideally we can get https://github.com/rxaviers/ecma402-fix-lookup-matcher to fit into |
@caridy, note https://github.com/rxaviers/ecma402-fix-lookup-matcher is about finding the bundle, not the parent, which is the first entry of the chain. For example, given the locale |
yes @rxaviers, the fact that all those algos will require the inheritance path to make a decision about the data availability, that's the piece we want to expose, so they can do that logic in user-land as well. |
It's in my TO-DO, but I got few spare time at the moment to go through it. Please, alert me in case I'm blocking you, but I will try to catch up time permitting. Thanks |
Here's the initial POC of the patch for Intl.js to implement the abstract locale operations discussed in the slides @caridy linked on Nov 23rd: andyearnshaw/Intl.js@master...zbraniecki:locale @caridy - does it look good? If so, I'll work on the spec patch. |
@zbraniecki let's work on the spec, and then we can review the implementation. In principle, it looks good. |
Here's the first draft of the spec - master...zbraniecki:locale-api |
@caridy @zbraniecki sorry for the long delay on this reply and for my short worded comments above, but the end of the year has been intensive. First of all, great job with the Locale API, it's a good way of exposing these info and will definitely benefit custom libraries and polyfills. How can I help you to get https://github.com/rxaviers/ecma402-fix-lookup-matcher into |
Heads up, this has been advanced to Stage 2 as of today. I'm going to work on updating the spec/polyfill now to @rxaviers and TC39 feedback and will submit it to reviewers in a couple weeks. |
CLDR defines groups of supplemental data for each territory, like http://www.unicode.org/cldr/charts/28/supplemental/territory_information.html And the full data set here: http://unicode.org/repos/cldr/trunk/common/supplemental/supplementalData.xml Perhaps a good future-proof solution would be to base the method names on these groups, e.g.:
which would return:
Or:
which would return:
And for a different French-speaking territory:
which would return:
This is a bit verbose but it maps the CLDR data one-to-one which should make it much easier to extend it in the future. |
FWIW, find CLDR in the JSON format here https://github.com/unicode-cldr/cldr-core/tree/master/supplemental. |
As I mentioned in #6 I landed Also, instead of I'll be happy to revisit it and move away from that API toward any standard that ECMA402 will come up with. |
Is there any further discussion on |
We haven't discuss it recently, but probably something that we will get back to at some point. |
Merge pull request #2818 from dilijev:intl-getCanonicalLocales https://tc39.github.io/ecma402/#sec-intl.getcanonicallocales https://tc39.github.io/ecma402/#sec-canonicalizelocalelist See: tc39/ecma402#78 tc39/ecma402#46 Fixes #2770.
Some of the information in the IANA language subtag registry, a registry from which the following may be derived, may be incomplete, but I wonder whether the existing information present could be used to supply This would, I imagine, be useful information for i18n as e.g., a user with language "in" (an encompassed language with parent macrolanguage "ms") could be directed to a "ms" locale if an "in" one could not be found. The writing system could conceivably be different, but if the "Suppress-Script" information were available to languages too (see #205), compatibility here could be detected as well.) |
I'm also looking for something like |
https://www.unicode.org/reports/tr35/#LanguageMatching proposes an algorithm to find a best fit for given sets of available and requested languages. Could this be referenced in the spec - or maybe even integrated? https://github.com/rxaviers/cldrjs/blob/master/doc/bundle_lookup_matcher.md describes more details about issues with this algorithm. |
I see several discussions in this thread. Let's move discussion of Intl.getCalendarInfo() over to #6, and use this thread to focus on the language matcher issues. |
FWIW: if weekday references end up numbers instead of weekday name abbreviation names, as in CLDR (probably a good thing), it would be internally consistent to sync those numbers up with ECMA-262's data type |
|
No. As suggested in #46 (comment), this issue is about language matching. It would be fixed by the Intl.LocaleMatcher proposal. |
UPDATE: Latest Proposal - Nov 2015
I started working on a spec and polyfill for Intl.Locale API.
I should have some proposal for this next week. Currently I have five functions on it:
The rationale for those five are:
This allows testing language tag for sanitation/validation purposes.
This is the core function allowing all language negotiation operations
this exposes the core function used by all Intl formatters that allows people to write their own custom formatters or polyfills.
This is basic language negotiation function for all localization libraries. It takes requestedLocales list (navigator.languages or custom), availableLocales (app provided locales), and a fallback defaultLocale (default app locale, not default host env locale) and returns the list of prioritized available locales that best matches user requested locales.
Simple function allowing l10n libraries to set html.dir based on their negotiated locale.
@caridy - One question I'd like to get help with is about using
Set
instead ofArray
. In all cases where we carry a list of locales, we always want it deduplicated andSet
does just that. It would be sweet to use it instead of anArray
, but it's API seems to be significantly less user friendly than that of theArray
- it's impossible to just retrievelocales[0]
, it's not easy tomap
etc.Should I stick to
Array
or try to useSet
?The text was updated successfully, but these errors were encountered: