Spaces:
Running
on
T4
Running
on
T4
const LANG3_FULL = { | |
eng: 'english', | |
arb: 'arabic', | |
asm: 'assamese', | |
bel: 'belarusian', | |
bul: 'bulgarian', | |
ben: 'bengali', | |
cat: 'catalan', | |
ces: 'czech', | |
cym: 'welsh', | |
dan: 'danish', | |
deu: 'german', | |
ell: 'greek', | |
spa: 'spanish', | |
est: 'estonian', | |
pes: 'persian', | |
fin: 'finnish', | |
fra: 'french', | |
hin: 'hindi', | |
hun: 'hungarian', | |
ind: 'indonesian', | |
ita: 'italian', | |
jpn: 'japanese', | |
kat: 'georgian', | |
lit: 'lithuanian', | |
lvs: 'latvian', | |
khk: 'mongolian', | |
mar: 'marathi', | |
mlt: 'maltese', | |
nld: 'dutch', | |
pan: 'punjabi', | |
pol: 'polish', | |
por: 'portuguese', | |
ron: 'romanian', | |
rus: 'russian', | |
slk: 'slovak', | |
slv: 'slovenian', | |
swe: 'swedish', | |
swh: 'swahili', | |
tam: 'tamil', | |
tha: 'thai', | |
tur: 'turkish', | |
ukr: 'ukrainian', | |
urd: 'urdu', | |
uzn: 'uzbek', | |
vie: 'vietnamese', | |
cmn: 'chinese', | |
afr: 'afrikaans', | |
isl: 'icelandic', | |
ltz: 'luxembourgish', | |
nob: 'norwegian', | |
glg: 'galician', | |
bos: 'bosnian', | |
hrv: 'croatian', | |
mkd: 'macedonian', | |
srp: 'serbian', | |
hye: 'armenian', | |
azj: 'azerbaijani', | |
kaz: 'kazakh', | |
kor: 'korean', | |
guj: 'gujarati', | |
kan: 'kannada', | |
npi: 'nepali', | |
snd: 'sindhi', | |
tel: 'telugu', | |
jav: 'javanese', | |
zlm: 'malay', | |
mal: 'malayalam', | |
tgl: 'tagalog', | |
mya: 'myanmar', | |
khm: 'khmer', | |
lao: 'lao', | |
heb: 'hebrew', | |
pbt: 'pashto', | |
tgk: 'tajik', | |
amh: 'amharic', | |
lin: 'lingala', | |
som: 'somali', | |
yor: 'yoruba', | |
sna: 'shona', | |
mri: 'maori', | |
hau: 'hausa', | |
oci: 'occitan', | |
bak: 'bashkir', | |
bre: 'breton', | |
yid: 'yiddish', | |
hat: 'haitian creole', | |
mlg: 'malagasy', | |
sin: 'sinhala', | |
sqi: 'albanian', | |
sun: 'sundanese', | |
eus: 'basque', | |
nno: 'nynorsk', | |
tat: 'tatar', | |
bod: 'tibetan', | |
fao: 'faroese', | |
haw: 'hawaiian', | |
lat: 'latin', | |
san: 'sanskrit', | |
tuk: 'turkmen' | |
}; | |
export function getLanguageFromThreeLetterCode(code: string): string | null { | |
try { | |
const name = LANG3_FULL[code] ?? null; | |
if (name == null) { | |
return null; | |
} | |
const capitalizedWords = name | |
.split(' ') | |
.map((word: string) => word[0].toUpperCase() + word.slice(1)); | |
return capitalizedWords.join(' '); | |
} catch (e) { | |
console.warn(`Unable to get language name for code ${code}: ${e}`); | |
} | |
return null; | |
} | |