function convertLanguageCodesToNames(languageCodes, authToken, callback) {
  let names = new Array(languageCodes.length);
  let unmatchabledLangs = [];
  languageCodes.forEach((code, i) => {
    if (_.isNil(code)) {
      names[`${i}`] = null;
    } else if (Object.prototype.hasOwnProperty.call(COMMON_LANGUAGES, code)) {
      names[`${i}`] = COMMON_LANGUAGES[`${code}`];
    } else {
      unmatchabledLangs.push(i);
    }
  });
  if (unmatchabledLangs.length > 0) {
    axios.defaults.headers.common['X-CSRF-Token'] = authToken;
    axios
      .post(`${window.BASE_PATH}/languages/translate_languages`, { language_codes: unmatchabledLangs.map(i => languageCodes[`${i}`]) })
      .then(val => {
        const res = val.data.display_names;
        unmatchabledLangs.forEach((indexVal, responseIndex) => {
          names[`${indexVal}`] = res[`${responseIndex}`];
        });
        callback(names);
      })
      .catch(err => {
        reportError(err);
      });
  } else {
    callback(names);
  }
}
/**
 * This function attempts to convert an array of iso code strings to an array of iso display names
 * i.e. ['eng', null, 'spa'] to ['English', null, 'Spanish']
 * We keep a list of the most common translations above. They will cover at least 90% of all translations
 * If we can't match it there, we make a call to the back-end to look the up (for only the unmatchable ones)
 * @param {Array} languageCodes - An array of strings of language codes (must be valid). Nulls are allowed, but will be filtered out
 * @param {String} authToken - the authToken
 * @param {Function} callback - a callback function to set the values on the front-end when this finishes
 * @return {Array} Returns array of translated language codes (leaves nulls as nulls)
 */
This function attempts to convert an array of iso code strings to an array of iso display names
i.e.
This function attempts to convert an array of iso code strings to an array of iso display names i . e .
function convertLanguageCodesToNames(languageCodes, authToken, callback) {
  let names = new Array(languageCodes.length);
  let unmatchabledLangs = [];
  languageCodes.forEach((code, i) => {
    if (_.isNil(code)) {
      names[`${i}`] = null;
    } else if (Object.prototype.hasOwnProperty.call(COMMON_LANGUAGES, code)) {
      names[`${i}`] = COMMON_LANGUAGES[`${code}`];
    } else {
      unmatchabledLangs.push(i);
    }
  });
  if (unmatchabledLangs.length > 0) {
    axios.defaults.headers.common['X-CSRF-Token'] = authToken;
    axios
      .post(`${window.BASE_PATH}/languages/translate_languages`, { language_codes: unmatchabledLangs.map(i => languageCodes[`${i}`]) })
      .then(val => {
        const res = val.data.display_names;
        unmatchabledLangs.forEach((indexVal, responseIndex) => {
          names[`${indexVal}`] = res[`${responseIndex}`];
        });
        callback(names);
      })
      .catch(err => {
        reportError(err);
      });
  } else {
    callback(names);
  }
}
function convertLanguageCodesToNames ( languageCodes , authToken , callback ) { let names = new Array ( languageCodes . length ) ; let unmatchabledLangs = [ ] ; languageCodes . forEach ( ( code , i ) => { if ( _ . isNil ( code ) ) { names [ ` ${ i } ` ] = null ; } else if ( Object . prototype . hasOwnProperty . call ( COMMON_LANGUAGES , code ) ) { names [ ` ${ i } ` ] = COMMON_LANGUAGES [ ` ${ code } ` ] ; } else { unmatchabledLangs . push ( i ) ; } } ) ; if ( unmatchabledLangs . length > 0 ) { axios . defaults . headers . common [ 'X-CSRF-Token' ] = authToken ; axios . post ( ` ${ window . BASE_PATH } ` , { language_codes : unmatchabledLangs . map ( i => languageCodes [ ` ${ i } ` ] ) } ) . then ( val => { const res = val . data . display_names ; unmatchabledLangs . forEach ( ( indexVal , responseIndex ) => { names [ ` ${ indexVal } ` ] = res [ ` ${ responseIndex } ` ] ; } ) ; callback ( names ) ; } ) . catch ( err => { reportError ( err ) ; } ) ; } else { callback ( names ) ; } }
This function attempts to convert an array of iso code strings to an array of iso display names
 i.e.
This function attempts to convert an array of iso code strings to an array of iso display names i . e .