How to use the i18n-iso-countries.alpha3ToAlpha2 function in i18n-iso-countries

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cboard-org / cboard / src / i18n.js View on Github external
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}`;
}
github HaliteChallenge / Halite-III / website / javascript / templates / UserProfile.vue View on Github external
getLocation: function () {
          const user = this.user
          let state = '', country = ''
          const countries = require('i18n-iso-countries')

          if (user.country_code) {
            const countryAlpha2 = countries.alpha3ToAlpha2(user.country_code)
            const countryData = iso3166.data[countryAlpha2]
            let stateData
            if (countryData && user.country_subdivision_code) {
              stateData = countryData.sub[user.country_subdivision_code]
            }
            state = stateData ? stateData.name : ''
            country = countryData ? countryData.name : ''
          }
          const location = `${state ? state + ', ' : ''}${country}`
          return location || ''
        },
        fetchChallengeGames() {