globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

List languages and it's codes #734

Closed weeco closed 7 years ago

weeco commented 7 years ago

Hello, I would like to list all languages (full name) and it's language code. Is that possible with globalize? I couldn't find something to list languages in your documentation.

rxaviers commented 7 years ago

CLDR does have the information you're looking for: https://github.com/unicode-cldr/cldr-localenames-full/blob/master/main/en/languages.json

You can use cldr.js directly (or via globalize). After running getting started steps, run:

Globalize('en').cldr.main('localeDisplayNames/languages/es')
> 'Spanish'

Note this doesn't work using globalize-compiler or globalize-runtime modules.

rxaviers commented 7 years ago

I'm closing the issue, but I can reopen if needed.