ES6 JavaScript module for looking up ISO 639-1 language code info.
import { Language } from "https://esm.sh/gh/doga/[email protected]/mod.mjs";
Tip: Run the following example by typing this in your terminal (requires Deno):
deno run \
--allow-net --allow-run --allow-env --allow-read \
https://deno.land/x/[email protected]/mod.ts \
--dax=false --mode=isolated \
https://raw.githubusercontent.com/doga/language/main/README.md
Print out language info for some language codes.
description = ''' Running this example is safe, it will not read or write anything to your filesystem. '''
import { Language } from "https://esm.sh/gh/doga/[email protected]/mod.mjs";
['en', 'fr', 'de', 'tr'].forEach(iso639_1 => {
const lang = Language.fromCode(iso639_1);
if(!lang)return;
console.info(`Language info for ${lang}:`);
console.info(` ISO 639-1: ${lang.iso639_1}`);
console.info(` ISO 639-2: ${lang.iso639_2}`);
console.info(` Name: ${lang.name}`);
console.info(` Native name: ${lang.nativeName}`);
console.info(` Family: ${lang.family}`);
console.info(` Wiki URL: ${lang.wikiUrl}`);
});
Sample output for the code above:
Language info for en:
ISO 639-1: "en"
ISO 639-2: "eng"
Name: "English"
Native name: "English"
Family: "Indo-European"
Wiki URL: "https://en.wikipedia.org/wiki/English_language"
Language info for fr:
ISO 639-1: "fr"
ISO 639-2: "fra"
Name: "French"
Native name: "français, langue française"
Family: "Indo-European"
Wiki URL: "https://en.wikipedia.org/wiki/French_language"
Language info for de:
ISO 639-1: "de"
ISO 639-2: "deu"
Name: "German"
Native name: "Deutsch"
Family: "Indo-European"
Wiki URL: "https://en.wikipedia.org/wiki/German_language"
Language info for tr:
ISO 639-1: "tr"
ISO 639-2: "tur"
Name: "Turkish"
Native name: "Türkçe"
Family: "Turkic"
Wiki URL: "https://en.wikipedia.org/wiki/Turkish_language"
∎