This is a custom token that is almost the same as the Very Basic Custom Token, so I will not repeat the information from that page. Please view that page to see how to get started creating your own custom token.

This custom token takes advantage of an entity query to get information from the database based on a value in the page url. The url for my use case is www.example.com/cloud/zzz. What I wanted to do was use that last three letter code (zzz) to pull a language name from the the database. Feel free to ask questions or critique my methods.

<?php
  $language_name = "language name not set";
  $path = current_path();  //returns cloud/zzz
  $code = substr($path, 6, 3);
  $condition2 = "use as needed in the query"
  $query = new EntityFieldQuery;
  $result = $query->entityCondition('entity_type', 'node')
        ->entityCondition('bundle', 'language')
        ->fieldCondition('field_iso_639_3', 'value', $code)
        ->fieldCondition('field_condition2', 'value', $condition2)
        ->execute();
  $node = node_load(reset(array_keys($result['node'])));
  $language_name = $node->field_language_print_name['und'][0]['value'];
  return $language_name;
?>

The custom token in this case is [custom:language-name].