JavaScript - get the complete list of locales supported by the browser

后端 未结 2 2189
忘掉有多难
忘掉有多难 2021-02-19 03:59

I\'ve found supportedLocalesOf, but is there a way to get all supported locales, not just check which among a given list are supported?

The \'*\' tag option des

相关标签:
2条回答
  • 2021-02-19 04:37

    I looked at this a little bit, and did some testing use Chrome.

    navigator.languages
    

    This returns an array of supported languages. Initially mine was only en-Us and en, however I added Welsh, and it was returned.

    0 讨论(0)
  • 2021-02-19 04:51

    The locale used and the form of the string returned are entirely implementation-dependen. It uses a string with a BCP 47 language tag. It is somehow still related to unicode locale.

    You still can find the list of locales argument in Country Code list. But if some of the country code does not work, you can go UNICODE LOCALE DATA MARKUP LANGUAGE (LDML) to see the list of correct locales implemented there.

    Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation

    0 讨论(0)
提交回复
热议问题