How to use the iso-639-1.validate function in iso-639-1

To help you get started, we’ve selected a few iso-639-1 examples, based on popular ways it is used in public projects.

github GuillaumeLeclerc / vue-seo / src / middlewares / autoLangDisplayer.vue View on Github external
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
    };
  }
github dphiffer / firewall-cafe / server / index.js View on Github external
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;
		}
github dphiffer / firewall-cafe / server / index.js View on Github external
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;
		}
	}
}