Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function standardizeLanguageCode(lang) {
const splittedLang = lang.split(splitLangRgx);
if (splittedLang.length < 1) {
return lang;
}
let standardLang =
splittedLang[0].length === 3
? alpha3TToAlpha2(splittedLang[0])
: splittedLang[0];
if (splittedLang.length === 1) {
return standardLang;
}
let standardCountry =
splittedLang[1].length === 3
? alpha3ToAlpha2(splittedLang[1])
: splittedLang[1];
return `${standardLang}-${standardCountry}`;
}