Git Product home page Git Product logo

Comments (8)

papandreou avatar papandreou commented on August 12, 2024 1

I dug around a bit, but CLDR docs are pretty sparse. The closest thing I could find was that some of the incomplete locales, such as nn, are littered with draft="unconfirmed" attributes:

<listPatternPart type="start" draft="unconfirmed">{0}, {1}</listPatternPart>

That doesn't really solve the <listPattern type="or"> problem though, as that is completely absent from the nn locale.

I'm out of ideas, so I'll close this for now. The "easy" fix was released in 5.0.0.

from node-cldr.

papandreou avatar papandreou commented on August 12, 2024

You're getting the data from the root locale, which all locales inherit from.

require('cldr').localeIds should be a list of locales that have data available. Does that solve your problem? I could also make the extract... functions throw or return nothing (not even the root data) in this case.

from node-cldr.

slavafomin avatar slavafomin commented on August 12, 2024

I think the best course of action would be to throw exception or just return null value. I'm not sure if every locale from localeIds actually has data (for example not all locales has pluralization function).

from node-cldr.

papandreou avatar papandreou commented on August 12, 2024

I landed a fix for this, but it turned out to be problematic when extracting from the supplemental folder where not every locale has its own file. I might revisit it later.

from node-cldr.

rotsee avatar rotsee commented on August 12, 2024

+1 on this.

At least it would be good to have a “strict mode”, where the library does not silently fall back to root. Even if this is only partially implemented (not working on supplemental data extraction), it would be an improvement, imho.

A typical use case is when working on a fallback chain of languages, e.g. ["nn", "no", "nb"] (nn has less than 100 % coverage in CLDR).

Here the English list pattern suddenly pops up out of nowhere...

from node-cldr.

papandreou avatar papandreou commented on August 12, 2024

Hmm, it would be fairly easy to just throw when attempting to extract data for a locale that does not exist in CLDR at all, but I'm not sure how to implement a strict mode like that. Since nn is in there: https://github.com/papandreou/node-cldr/blob/master/3rdparty/cldr/common/main/nn.xml it's hard to tell if the fallback to root is intentional or not.

For example, en.xml does not contain an entry for the America/Coral_Harbour time zone, so that will fall back to the entry in root.xml. Which is probably perfectly fine -- then the exemplar city will be Atikokan in the Englishes.

That being said I don't have a full overview of everything in the CLDR -- it could be that there's some information in there that would help detect when the fallback isn't intentional. Please prove me wrong :)

from node-cldr.

papandreou avatar papandreou commented on August 12, 2024

Implemented the easy one here: #73

from node-cldr.

rotsee avatar rotsee commented on August 12, 2024

For example, en.xml does not contain an entry for the America/Coral_Harbour time zone, so that will fall back to the entry in root.xml. Which is probably perfectly fine -- then the exemplar city will be Atikokan in the Englishes.

I see, reality is more complex than I imagined. As always.
I guess if there was a way to know what fallback level was actually used, the client could use that information for decide whether the fallback was appropriate for their particular situation, but I have no idea how that would work...

from node-cldr.

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.