Programmatically get the continent from ISO2 I am using the Countries module to assign countries and associated data to nodes. I am currently writing a custom token and only can access the ISO2 data for the value, not the associated data (full name, language, ISO3).

How can programmatically get the other data with only the ISO2?
Continuing the answer from the initial question, I think you have to load the Country entity to replace the token with what values you are after.

Based on looking at the Countries module, it stores countries as a custom entity:

/**
 * Implements hook_entity_info().
 */
function countries_entity_info() {
  $return = array(
    'country' =&gt; array(
      'label' =&gt; t('Country'),
      'plural label' =&gt; t('Countries'),
      'entity class' =&gt; 'Entity',
      'controller class' =&gt; 'EntityAPIControllerExportable',
      'base table' =&gt; 'countries_country',
      'token type' =&gt; 'country',
      'fieldable' =&gt; TRUE,
      'module' =&gt; 'countries',
      'entity keys' =&gt; array(
        'id' =&gt; 'cid',
        'name' =&gt; 'iso2',
        'label' =&gt; 'name',
      ),
      'bundles' =&gt; array(
        'country' =&gt; array(
          'label' =&gt; t('Country'),
          'admin' =&gt; array(
            'path' =&gt; 'admin/config/regional/countries',
            'access arguments' =&gt; array('administer site configuration'),
          ),
        ),
      ),
      'view modes' =&gt; array(
        'full' =&gt; array(
          'label' =&gt; t('Country'),
          'custom settings' =&gt; FALSE,
        ),
      ),
    ),
  );
  return $return;
}

/**
 * Loads a country entity by ISO alpha-2 code.
 *
 * This is also a menu wildcard loader.
 *
 * @param string $iso2
 *   An ISO alpha-2 string. This is case-insensitive.
 *
 * @return object
 *   A country object loaded by the entity controller.
 */
function country_load($iso2) {
  // The URL's should be case insensitive.
  $iso2 = $iso2 ? drupal_strtoupper($iso2) : $iso2;
  return entity_load_single('country', $iso2);
}


It looks like the iso2 value is the entity id, based on this code and the helper load function here, so, you can access the full entity when a token is replaced by:

/**
 * Implements hook_tokens().
 */
function MYMODULE_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = [];

  if ($type == 'node' &amp;&amp; !empty($data['node']) &amp;&amp; array_key_exists('MYTOKEN', $tokens)) {
    $country = country_load($data['node']-&gt;field_prgm_country[LANGUAGE_NONE][0]['iso2']);
    // $country should be a fully loaded Country entity with all its fields and properties
    // check out $country here with ksm($country);exit;
    $replacements['[node:MYTOKEN]'] = // data you want to show;
  }

  return $replacements;
}


It looks like the Country module provides its own country: scope of tokens, but I do not know how (or if) they work in the context of fields on a node. This should get you closer at least.