Spaces:
Running
on
T4
Running
on
T4
File size: 2,292 Bytes
6bfe941 2485dd8 6bfe941 2485dd8 6bfe941 2485dd8 6bfe941 2485dd8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
const LANG3_TO_NAME = {
afr: 'afrikaans',
amh: 'amharic',
arb: 'arabic',
asm: 'assamese',
azj: 'azerbaijani',
bak: 'bashkir',
bel: 'belarusian',
ben: 'bengali',
bod: 'tibetan',
bos: 'bosnian',
bre: 'breton',
bul: 'bulgarian',
cat: 'catalan',
ces: 'czech',
cmn: 'chinese',
cym: 'welsh',
dan: 'danish',
deu: 'german',
ell: 'greek',
eng: 'english',
est: 'estonian',
eus: 'basque',
fao: 'faroese',
fin: 'finnish',
fra: 'french',
glg: 'galician',
guj: 'gujarati',
hat: 'haitian creole',
hau: 'hausa',
haw: 'hawaiian',
heb: 'hebrew',
hin: 'hindi',
hrv: 'croatian',
hun: 'hungarian',
hye: 'armenian',
ind: 'indonesian',
isl: 'icelandic',
ita: 'italian',
jav: 'javanese',
jpn: 'japanese',
kan: 'kannada',
kat: 'georgian',
kaz: 'kazakh',
khk: 'mongolian',
khm: 'khmer',
kor: 'korean',
lao: 'lao',
lat: 'latin',
lin: 'lingala',
lit: 'lithuanian',
ltz: 'luxembourgish',
lvs: 'latvian',
mal: 'malayalam',
mar: 'marathi',
mkd: 'macedonian',
mlg: 'malagasy',
mlt: 'maltese',
mri: 'maori',
mya: 'myanmar',
nld: 'dutch',
nno: 'nynorsk',
nob: 'norwegian',
npi: 'nepali',
oci: 'occitan',
pan: 'punjabi',
pbt: 'pashto',
pes: 'persian',
pol: 'polish',
por: 'portuguese',
ron: 'romanian',
rus: 'russian',
san: 'sanskrit',
sin: 'sinhala',
slk: 'slovak',
slv: 'slovenian',
sna: 'shona',
snd: 'sindhi',
som: 'somali',
spa: 'spanish',
sqi: 'albanian',
srp: 'serbian',
sun: 'sundanese',
swe: 'swedish',
swh: 'swahili',
tam: 'tamil',
tat: 'tatar',
tel: 'telugu',
tgk: 'tajik',
tgl: 'tagalog',
tha: 'thai',
tuk: 'turkmen',
tur: 'turkish',
ukr: 'ukrainian',
urd: 'urdu',
uzn: 'uzbek',
vie: 'vietnamese',
yid: 'yiddish',
yor: 'yoruba',
zlm: 'malay',
};
export function getLanguageFromThreeLetterCode(
lang3Code: string,
): string | null {
try {
const name = LANG3_TO_NAME[lang3Code] ?? 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 ${lang3Code}: ${e}`);
}
return null;
}
|