resolve(lang, strObj) {
    if (strObj === undefined)
      return undefined;

    // We have a string in the specified language
    // Note that emptying a string reverts back to other available languages
    if (strObj[lang] !== undefined && strObj[lang] !== '')
      return {
        str: strObj[lang],
        lang
      };

    // Try specific fallbacks for this language first, e.g. European Portuguese
    // for Brazilian Portuguese. English is a declared fallback for all languages.
    let fallbackLanguages = languages.getFallbacks(lang);
    for (let fallbackLanguage of fallbackLanguages) {
      if (strObj[fallbackLanguage] !== undefined && strObj[fallbackLanguage] !== '')
        return {
          str: strObj[fallbackLanguage],
          lang: fallbackLanguage
        };
    }

    // Pick first available language
    let availableLanguages = Object.keys(strObj);
    for (let availableLanguage of availableLanguages) {
      if (languages.isValid(availableLanguage) &&
        strObj[availableLanguage] !== undefined &&
        strObj[availableLanguage] !== '')
        return {
          str: strObj[availableLanguage],
          lang: availableLanguage
        };
    }

    // This may not be a valid multilingual string object at all, or all strings
    // are empty.
    return undefined;

  }
/**
   * Find the best fit for a given language from a multilingual string object,
   * taking into account fallbacks.
   *
   * @param {String} lang
   *  the preferred language code of the target string
   * @param {Object} strObj
   *  a multilingual string object
   * @returns {ResolveResult}
   *  or undefined if we can't find any suitable string
   * @memberof MlString
   */
Find the best fit for a given language from a multilingual string object,
taking into account fallbacks.

@param {String} lang
the preferred language code of the target string
@param {Object} strObj
a multilingual string object
@returns {ResolveResult}
or undefined if we can't find any suitable string
@memberof MlString
Find the best fit for a given language from a multilingual string object taking into account fallbacks . @param { String } lang the preferred language code of the target string @param { Object } strObj a multilingual string object @returns { ResolveResult } or undefined if we can ' t find any suitable string @memberof MlString
resolve(lang, strObj) {
    if (strObj === undefined)
      return undefined;
    if (strObj[lang] !== undefined && strObj[lang] !== '')
      return {
        str: strObj[lang],
        lang
      };
    let fallbackLanguages = languages.getFallbacks(lang);
    for (let fallbackLanguage of fallbackLanguages) {
      if (strObj[fallbackLanguage] !== undefined && strObj[fallbackLanguage] !== '')
        return {
          str: strObj[fallbackLanguage],
          lang: fallbackLanguage
        };
    }
    let availableLanguages = Object.keys(strObj);
    for (let availableLanguage of availableLanguages) {
      if (languages.isValid(availableLanguage) &&
        strObj[availableLanguage] !== undefined &&
        strObj[availableLanguage] !== '')
        return {
          str: strObj[availableLanguage],
          lang: availableLanguage
        };
    }
    return undefined;
  }
resolve ( lang , strObj ) { if ( strObj === undefined ) return undefined ; if ( strObj [ lang ] !== undefined && strObj [ lang ] !== '' ) return { str : strObj [ lang ] , lang } ; let fallbackLanguages = languages . getFallbacks ( lang ) ; for ( let fallbackLanguage of fallbackLanguages ) { if ( strObj [ fallbackLanguage ] !== undefined && strObj [ fallbackLanguage ] !== '' ) return { str : strObj [ fallbackLanguage ] , lang : fallbackLanguage } ; } let availableLanguages = Object . keys ( strObj ) ; for ( let availableLanguage of availableLanguages ) { if ( languages . isValid ( availableLanguage ) && strObj [ availableLanguage ] !== undefined && strObj [ availableLanguage ] !== '' ) return { str : strObj [ availableLanguage ] , lang : availableLanguage } ; } return undefined ; }
Find the best fit for a given language from a multilingual string object,
 taking into account fallbacks.
Find the best fit for a given language from a multilingual string object taking into account fallbacks .
// We have a string in the specified language // Note that emptying a string reverts back to other available languages // Try specific fallbacks for this language first, e.g. European Portuguese // for Brazilian Portuguese. English is a declared fallback for all languages. // Pick first available language // This may not be a valid multilingual string object at all, or all strings // are empty.