Git Product home page Git Product logo

bcp-47's People

Contributors

cjbarth avatar greenkeeper[bot] avatar greenkeeperio-bot avatar wooorm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bcp-47's Issues

Singleton subtag appearing twice is considered valid

This package does not treat the tag en-a-bbb-a-ccc as invalid even though the singleton subtag a appears twice.

According to the BCP 47 specifications: Each singleton subtag MUST appear at most one time in each tag (other than as a private use subtag). That is, singleton subtags MUST NOT be repeated. For example, the tag "en-a-bbb-a-ccc" is invalid because the subtag 'a' appears twice. Note that the tag "en-a-bbb-x-a-ccc" is valid because the second appearance of the singleton 'a' is in a private use sequence.

Is this an issue that needs to be fixed?

Add name and scope support

I don't know if this is in the scope of this project, but when I got here I expected to get the actual name of the language of a parsed language tag. I realize this library currently just implements the specification itself and doesn't keep a list of all subtags, but maybe we can change that? Sure, the subtag registry is huge but also the only resource to get the actual language names and scopes from. I think with some tricks we can compress that list, especially regarding the redundant and grandfathered entries. Also, not all entries are languages, but just regions or scripts, since this is a list of all possible subtags. Some metadata:

  • 48149 lines
  • 711 KB
  • 9122 entries
  • 8178 entries with Type: language
  • a lot of entries have multiple Description values, it seems like just caring about the first one of each entry is enough
  • Some values are irrelevant here and can be omitted
  • converted to json it's "only" 655 KB big

Here is a short gist from me which converts the registry to a json that could be readable by this library:
https://gist.github.com/nnmrts/7f06da21729a7d495cdee147271847b5

TypeScript definitions

Is there any interest in a PR to include TypeScript definitions in this project? If so, I'd be glad to make a PR for them.

TLD > BCP 47 function?

Probably not scope of your package but I am longing for a function to return me a BCP 47 language tag based by a top level domain (TLD).

Have initially reported the need in petert82/country-query#3 but since it seems inactive, and yours comes - after some research - the most close, I wonder why not ask you about that?

TypeError: options.warning is not a function

Using the package as: const schema = parse('x-whatevertag', {warning: true}), results in error:

     if (options.warning) options.warning(reason, code, offset)
                                 ^
TypeError: options.warning is not a function
     at fail (file:///C:/Users/.../node_modules/bcp-47/lib/parse.js:288:34)
     at parse (file:///C:/Users/.../node_modules/bcp-47/lib/parse.js:258:18)
    at file:///C:/Users/.../src/test.js:3:16```

Webpack incompatability

In these referenced line, the import doesn't include the .json extension, which is creating problems for Webpack. Could this be fixed? I've already tested that just adding the extension fixes the problem. If a PR is welcome, I'd be glad to make it.

bcp-47/lib/parse.js

Lines 6 to 7 in ff06090

var regular = require('./regular')
var normal = require('./normalize')

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.