Skip to content

Add name and scope support #21

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

Closed
nnmrts opened this issue Feb 8, 2021 · 3 comments
Closed

Add name and scope support #21

nnmrts opened this issue Feb 8, 2021 · 3 comments

Comments

@nnmrts
Copy link

nnmrts commented Feb 8, 2021

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

@wooorm
Copy link
Owner

wooorm commented Feb 10, 2021

I feel this is something that can go well in a different package: the goal of this project is to be tiny and only support the spec.

I expected to get the actual name of the language of a parsed language tag

This would be incredible complex, a lot of combinations don’t really have names.
Anyway, most JS engines ship with a lot of intl data, so see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames

@wooorm wooorm closed this as completed Feb 10, 2021
@nnmrts
Copy link
Author

nnmrts commented Feb 10, 2021

Ugh, I always forget about the Intl object! Thanks, and yeah, you're right, this is not in the scope and since Intl exists, there is no need for it here.

@wooorm
Copy link
Owner

wooorm commented Feb 10, 2021

I do too ;) It’s pretty rad that it includes translations of everything 🤯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants