Coder Social home page Coder Social logo

Comments (12)

littledan avatar littledan commented on September 24, 2024 1

OK, I made a fancy v2 label for this. I'll leave the issue open for future development.

from proposal-intl-locale.

nciric avatar nciric commented on September 24, 2024 1

ICU supports part of this with addKeyValue, where value is empty. We could allow:

var loc = new Intl.Locale('en-u-ca-gregory', {calendar: ''});
// loc.calendar would return ''

Similar (but harder to implement) could be done with region and script. But I am not sure we would want this - what if you have 'zh-TW' and blindly remove region? It would push user to 'zh' which is simplified version.

I would rather implement minimize and maximize methods, or provide getters for language, script and region.

from proposal-intl-locale.

littledan avatar littledan commented on September 24, 2024 1

I'd like to express a strong preference for adding these in v2.

When we promoted the feature to stage 3, this indicated that we are done with it from a design standpoint and are ready to move to implementation. At the same time, we can present this method for a new staged proposal as early as the May TC39 meeting. Maybe it will even ship in browsers at the same time.

I'd like to limit additions to this proposal to things that are absolutely needed otherwise the other aspects of the proposal are broken.

from proposal-intl-locale.

littledan avatar littledan commented on September 24, 2024

@anba We could add a method for this.

Can you think of a case of needing it in an application? This could help guide the appropriate API shape.

Do you think this is a very core, common need? That would drive its inclusion in this proposal, as opposed to a follow-on proposal.

from proposal-intl-locale.

anba avatar anba commented on September 24, 2024

Can you think of a case of needing it in an application? This could help guide the appropriate API shape.

Java's Locale.Builder allows to clear subtags, but when I was searching for Locale.Builder uses on GitHub most of the time only test or example code shows up. 😒 So I can't provide a definite use case for this functionality right now.

The mailing list and the design notes for Locale.Builder also don't provide any insights why Locale.Builder supports this functionality. Or rather, at least I didn't see any notes when skimming over the documents, but maybe I've just missed it.

Do you think this is a very core, common need? That would drive its inclusion in this proposal, as opposed to a follow-on proposal.

From what I've understood, this proposal aims to provide a minimal API surface for locales (e.g. it doesn't provide access to the variant and privateuse subtags or extension subtags besides some selected keywords for the Unicode extension subtag). And I'm okay with that approach, as long as we keep it extensible to be able to add more functionality in the future when needed. (Insert "Captain Obvious" image here. 😛)

So, if no one else shows up to support this functionality, I wouldn't be mad if we defer it and keep it out of the Locale v1 API.

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on September 24, 2024

What would happen if you did:

let loc = new Intl.Locale("sr-Cyrl-SR", {script: ""});

I can imagine this returning sr-SR.

from proposal-intl-locale.

nciric avatar nciric commented on September 24, 2024

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on September 24, 2024

but the question is - is it useful?

Sure, I share your concern about people using it without understanding the consequences (removing CN from zh-CN), but I do see some use cases.

For example, in the language negotiation strategy we're using at Mozilla, one of the steps is to compare the list of available locales against the requested locale with some subtags cleared (in order to be treated as a range - en-*). We currently have private methods like locale.clearRegion() or locale.clearVariants() and once we switch to this API, I'd use the provided example to achieve the same.

Here's the documentation of our algorithm - https://searchfox.org/mozilla-central/source/intl/locale/LocaleService.cpp#378

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on September 24, 2024

Hmm, actually, I think that minimize method would work even better here. So I'm totally ok going for that as @nciric suggests instead of some way to remove subtags.

from proposal-intl-locale.

littledan avatar littledan commented on September 24, 2024

@nciric I like the idea of minimize and maximize methods. Do you think we should do these in v1, or would it be OK to address in a follow-on proposal? As Intl.Locale I'd already at Stage 3, and it doesn't sound like those methods would require any changes to this proposal, just an additional, a follow-on proposal seems procedurally easier.

from proposal-intl-locale.

nciric avatar nciric commented on September 24, 2024

@littledan - what would be a product of minimize and maximize methods? A new locale object based on minimized/maximized form? Or just a locale string, that can be used to create new Locale object?

Either way, ICU provides trivial way of implementing both, so from that standpoint it can be part of v1.

We just need to make sure to curb feature creep into locale v1 - otherwise we'll never be done (just look at number of methods in ICU u_loc).

from proposal-intl-locale.

zbraniecki avatar zbraniecki commented on September 24, 2024

a new Locale object imho.

from proposal-intl-locale.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.