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

TLD > BCP 47 function? #17

Closed
binarykitchen opened this issue Aug 24, 2017 · 3 comments
Closed

TLD > BCP 47 function? #17

binarykitchen opened this issue Aug 24, 2017 · 3 comments

Comments

@binarykitchen
Copy link

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?

@wooorm
Copy link
Owner

wooorm commented Aug 24, 2017

Interesting problem! And hi, Michael 👋

First: this should definitely be another project. Maybe you could do a map of TLDs to BCP-47 tags, in JSON, but it should be outside bcp-47.

Second: There are quite some TLDs (generic, test, infrastructure) that do not map to anything related to your problem.

Third: TLDs are for countries (they’re often based on ISO 3166-1). BCP-47 is for languages. Some languages come with some geography information (e.g., en-GB for English as spoken in Greater Britain). But, regions could be added to any language. nl-GB, which would stand for Dutch as spoken in GB, is valid.

To recap the biggest problem with your question: the .nl TLD (Netherlands), does not say anything about the site being in Dutch. Sites could be (and often are) in English or Frisian. Or anything else really.
Although Dutch is indeed the most common language in The Netherlands, not all regions have a favourite language.

@binarykitchen
Copy link
Author

binarykitchen commented Aug 24, 2017

hey dude

thanks for the good feedback. totally agree in all points. let me explain the use case i have here to crack that problem:

on www.videomail.io (try it out), users can enter recipient email addresses. when recipient views the videomail, the sent date is shown but always in the wrong format. hence i am thinking of a tld to bcp 47 converter for better date display. tld is based on the recipient's email address. that new project could be called email-to-bcp47 or tld-to-bcp47 whatever.

totally aware that this isn't entirely accurate (see your dutch example) but it is still better than always displaying the hardcoded date format

thoughts?

@wooorm
Copy link
Owner

wooorm commented Aug 31, 2017

I’d suggest using the Date JavaScript object to infer timezones (see moment, moment-timezone), and detecting the language the user prefers (see locale2) instead!

I’d sa it’s a bad idea to do anything with bcp-47, and anyway, it should be a separate package!

@wooorm wooorm closed this as completed Aug 31, 2017
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