我正在建立一个网站,人们可以在其中将语言信息与内容相关联.
I'm building a website where people can associate a language information to content.
网站大量使用 Javascript,与各种元素相关的语言信息在内部被视为 ISO 639-1 代码.
The website uses Javascript heavily and the language information associated to various elements is treated internally as an ISO 639-1 code.
如何以用户的语言显示语言名称列表?
How to show a list of language names - in the language of the user ?
在 new(ish) 国际 API:
There is a native support for this in the new(ish) Intl API:
let languageNames = new Intl.DisplayNames(['en'], {type: 'language'});
languageNames.of('fr'); // "French"
languageNames.of('de'); // "German"
languageNames.of('fr-CA'); // "Canadian French"
这篇关于Javascript 中 ISO 639-1 代码中的语言名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!