Skip to content
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

Function to return a BCP 47 language tag #3

Closed
binarykitchen opened this issue Aug 16, 2017 · 2 comments
Closed

Function to return a BCP 47 language tag #3

binarykitchen opened this issue Aug 16, 2017 · 2 comments

Comments

@binarykitchen
Copy link

For some complex date handling I am looking for a function which returns me a BCP 47 language tag based on a TLD alone.

The locales parameter in this infamous function

dateObj.toLocaleTimeString([locales[, options]])

(see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString)

can be a string with a BCP 47 language tag. Unfortunately you do not return a BCP 47 language tag in your results.

Could that be added in your array? And for performance, introduce a flag so that only this one is returned without anything else.

Thanks!

@binarykitchen
Copy link
Author

@petert82 hello?

@petert82
Copy link
Owner

Hi,
I think this would be best accomplished via a change to the source dataset. You'd probably be best directing a request to add the extra data needed there.

If that's not possible, and you're really concerned about performance, you might be better served by just pre-compiling your own mapping of TLDs to BCP 47 lang tags (you could I think construct these from the data in the mledoze/countries data plus a mapping of 3-letter language codes to 2-letter codes).

@petert82 petert82 closed this as completed Nov 2, 2019
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