0

In JavaScript I can get user language code using

var code = window.navigator.userLanguage || winodw.navigator.language; //en-US, fr

How can I get language display name using this codes. An API would be a preferred option, not static list maintaining all possible codes

mplungjan
  • 169,008
  • 28
  • 173
  • 236
user987316
  • 894
  • 4
  • 13
  • 35

2 Answers2

2

You can checkout the below projects in GitHub,

language-tags - https://github.com/mattcg/language-tags

For the underlying JSON data which the above project consumes you can checkout the below project,

language-subtag-registry - https://github.com/mattcg/language-subtag-registry

Just in case, if you don't prefer to use the above libraries and you want to have a predefined list of language code/names (on which you can manipulate) you can checkout the below post,

List of Language Codes in YAML or JSON?

Hope this helps!

Community
  • 1
  • 1
David R
  • 14,711
  • 7
  • 54
  • 72
0

You don't have a direct solution I guess. You can use the following ISO Language code files (JSON,CSV) and read from it.

ISO Language Code files

Keppy
  • 471
  • 1
  • 7
  • 23