Language name from ISO 639-1 code in Javascript

前端 未结 6 1919
傲寒
傲寒 2020-12-19 00:04

I\'m building a website where people can associate a language information to content.

The website uses Javascript heavily and the language information associated to

6条回答
  •  粉色の甜心
    2020-12-19 00:53

    If you want a name of an arbitrary language in an arbitrary language (e.g, how to say "Korean language" in Japanese), you can use Unicode CLDR data.

    To use it in JavaScript, you may use cldr NPM package like:

    cldr.extractLanguageDisplayNames('it').en;
    # => 'inglese'
    

    But not sure if the package only supports Node.js or also supports browsers. If not, you may search for other libraries or write your own code to parse CLDR directly.

提交回复
热议问题