function navigateToLanguageAndCountryCode(language, countryCode) {
  var doc = document;
  var selectLangZoneTerms =
      doc.getElementById('play-footer').getElementsByTagName('select')[0];

  var applyTermsForLangAndZone = function(termsLang) {
    // Check special case for en_us which may be mapped to en.
    var matchDefaultUs = null;
    if (window.location.href ==
            'https://play.google.com/intl/en_us/about/play-terms.html' &&
        termsLang == 'en' && countryCode == 'us' &&
        selectLangZoneTerms.value == '/intl/en/about/play-terms.html') {
      return true;
    }
    var matchByLangZone =
        '/intl/' + termsLang + '_' + countryCode + '/about/play-terms.html';
    if (selectLangZoneTerms.value == matchByLangZone) {
      // Already selected what is needed.
      return true;
    }
    for (var i = selectLangZoneTerms.options.length - 1; i >= 0; --i) {
      var option = selectLangZoneTerms.options[i];
      if (option.value == matchByLangZone) {
        window.location.href = option.value;
        return true;
      }
    }
    return false;
  };

  // Try two versions of the language, full and short (if it exists, for
  // example en-GB -> en). Note, terms may contain entries for both types, for
  // example: en_ie, es-419_ar, es_as, pt-PT_pt.
  if (applyTermsForLangAndZone(language)) {
    return true;
  }
  var langSegments = language.split('-');
  if (langSegments.length == 2 && applyTermsForLangAndZone(langSegments[0])) {
    return true;
  }

  return false;
}
/**
 * Analyzes current document and tries to find the link to the Play Store ToS
 * that matches requested |language| and |countryCode|. Once found, navigate
 * to this link and returns True. If no match was found then returns False.
 */
Analyzes current document and tries to find the link to the Play Store ToS
that matches requested |language| and |countryCode|. Once found, navigate
to this link and returns True. If no match was found then returns False.
Analyzes current document and tries to find the link to the Play Store ToS that matches requested |language| and |countryCode| . Once found navigate to this link and returns True . If no match was found then returns False .
function navigateToLanguageAndCountryCode(language, countryCode) {
  var doc = document;
  var selectLangZoneTerms =
      doc.getElementById('play-footer').getElementsByTagName('select')[0];
  var applyTermsForLangAndZone = function(termsLang) {
    var matchDefaultUs = null;
    if (window.location.href ==
            'https://play.google.com/intl/en_us/about/play-terms.html' &&
        termsLang == 'en' && countryCode == 'us' &&
        selectLangZoneTerms.value == '/intl/en/about/play-terms.html') {
      return true;
    }
    var matchByLangZone =
        '/intl/' + termsLang + '_' + countryCode + '/about/play-terms.html';
    if (selectLangZoneTerms.value == matchByLangZone) {
      return true;
    }
    for (var i = selectLangZoneTerms.options.length - 1; i >= 0; --i) {
      var option = selectLangZoneTerms.options[i];
      if (option.value == matchByLangZone) {
        window.location.href = option.value;
        return true;
      }
    }
    return false;
  };
  if (applyTermsForLangAndZone(language)) {
    return true;
  }
  var langSegments = language.split('-');
  if (langSegments.length == 2 && applyTermsForLangAndZone(langSegments[0])) {
    return true;
  }
  return false;
}
function navigateToLanguageAndCountryCode ( language , countryCode ) { var doc = document ; var selectLangZoneTerms = doc . getElementById ( 'play-footer' ) . getElementsByTagName ( 'select' ) [ 0 ] ; var applyTermsForLangAndZone = function ( termsLang ) { var matchDefaultUs = null ; if ( window . location . href == 'https://play.google.com/intl/en_us/about/play-terms.html' && termsLang == 'en' && countryCode == 'us' && selectLangZoneTerms . value == '/intl/en/about/play-terms.html' ) { return true ; } var matchByLangZone = '/intl/' + termsLang + '_' + countryCode + '/about/play-terms.html' ; if ( selectLangZoneTerms . value == matchByLangZone ) { return true ; } for ( var i = selectLangZoneTerms . options . length - 1 ; i >= 0 ; -- i ) { var option = selectLangZoneTerms . options [ i ] ; if ( option . value == matchByLangZone ) { window . location . href = option . value ; return true ; } } return false ; } ; if ( applyTermsForLangAndZone ( language ) ) { return true ; } var langSegments = language . split ( '-' ) ; if ( langSegments . length == 2 && applyTermsForLangAndZone ( langSegments [ 0 ] ) ) { return true ; } return false ; }
Analyzes current document and tries to find the link to the Play Store ToS
 that matches requested |language| and |countryCode|.
Analyzes current document and tries to find the link to the Play Store ToS that matches requested |language| and |countryCode| .
// Check special case for en_us which may be mapped to en. // Already selected what is needed. // Try two versions of the language, full and short (if it exists, for // example en-GB -> en). Note, terms may contain entries for both types, for // example: en_ie, es-419_ar, es_as, pt-PT_pt.