iso-639-2
This ISO 639-2 JavaScript library works in NodeJS and modern web browsers.
It provides a function to get an array of all languages, sorted by alpha-3
code, alpha-2 code, native name, English name, or reading direction
(LTR or RTL). It also provides a function to look up a language by the
alpha-3 or alpha-2 code.
As of 14 July 2014, all 486 languages listed on the official Library of Congress web page are supported.
API
-
languages.getLanguages(sortBy, isAlpha2Code): Returns an array of sorted language objects. Default sortBy is "a3". Default isAlpha2Code is false.
-
languages.getLanguage(languageCode, isAlpha2Code): Returns a language object that matches the languageCode. Default isAlpha2Code is false.
-
languages.getLabel(propertyName): Returns the label associated with the propertyName. Valid property names are a3, a3t, a2, name, eng, dir.
-
languages.isValid(languageCode, isAlpha2Code): Returns true if a language object is found that matches the languageCode. Default isAlpha2Code is false.
-
languages.isRtl(languageCode, isAlpha2Code): Returns true if a language object is found that matches the languageCode and has a dir property value of rtl.
NodeJS Usage
var languages = ; var langs = languages; for i=0 len=langslength; i<len; i++ lang = langsi; console; console; console;
Browser Usage
ISO 639-2 Languages Module ISO 639-2 Languages Module Test