Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const domainGenerator = (code, def) => {
const host = window.location.hostname;
const hostParts = host.split('.');
const first = hostParts[0];
let curr = null;
if (langCodes.validate(first)) {
curr = hostParts.shift();
}
hostParts.unshift(code);
const current = (curr === null) ? code === def : code === curr;
if (hostParts[0] === def) {
hostParts.shift();
}
return {
url: window.location.href.replace(host, hostParts.join('.')),
current,
code
};
}
function getLanguageName(langCode) {
if (ISO6391.validate(langCode)) {
return ISO6391.getName(langCode);
} else {
var langInfo = BCP47.parse(langCode);
if (ISO6391.validate(langInfo.language)) {
var name = ISO6391.getName(langInfo.language);
if (name == 'Chinese') {
if (langInfo.region == 'CN') {
name += ' (Simplified)';
} else if (langInfo.region == 'TW') {
name += ' (Traditional)';
}
}
return name;
} else {
return langCode;
}
function getLanguageName(langCode) {
if (ISO6391.validate(langCode)) {
return ISO6391.getName(langCode);
} else {
var langInfo = BCP47.parse(langCode);
if (ISO6391.validate(langInfo.language)) {
var name = ISO6391.getName(langInfo.language);
if (name == 'Chinese') {
if (langInfo.region == 'CN') {
name += ' (Simplified)';
} else if (langInfo.region == 'TW') {
name += ' (Traditional)';
}
}
return name;
} else {
return langCode;
}
}
}