Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Language name from ISO 639-1 code in Javascript

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 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 ?

like image 711
aberaud Avatar asked Jun 12 '12 12:06

aberaud


People also ask

What language does ISO use?

Language matters That's why, since 1947, we have had three official languages: English, French and Russian. It helps involve greater numbers of people in the process by making information about what we're working on, and why standardization matters, available in three widely-spoken languages.

How do I get language code?

Go to command line and run bundle install (must be in your application's directory). Then run linguist app/test. tpl (more generally linguist <path-to-code-snippet-file> ). It will tell you the type, mime type, and language.

How many languages are used in ISO?

There are 58 languages in ISO 639-2 which are considered, for the purposes of the standard, to be "macrolanguages" in ISO 639-3.


1 Answers

There are some similar questions on stackoverflow. I needed a javascript function for getting English names and Native names for different languages. I found a nice json formatted list of ISO 693-1 language codes on stackoverflow (based on wikipedia) and created a gist with two functions getLanguageName and getLanguageNativeName. Here is how to use it:

getLanguageNativeName("cv"); // --> "чӑваш чӗлхи"
getLanguageName("cv"); // --> "Chuvash"
getLanguageNativeName("cv-RU"); // --> "чӑваш чӗлхи"
getLanguageName("cv-RU"); // --> "Chuvash"

I used it to answer another similar question: generate a list of localized language names with links to google translate

like image 70
Anatoly Mironov Avatar answered Oct 13 '22 18:10

Anatoly Mironov