--- unitsapi.module_ORIG	2009-02-27 18:02:28.000000000 -0500
+++ unitsapi.module	2009-11-03 18:58:33.000000000 -0500
@@ -18,6 +18,69 @@ function unitsapi_help($path, $arg) {
 }
 
 /**
+ * Implimentation of hook_define_units() from the Units module.
+ *
+ * Exposes all units defined in the units.xml to the units module.
+ *
+ * Converts this format:
+ *   'millimeter' => Array
+ *       (
+ *           'singular' => 'millimeter',
+ *           'plural'   => 'millimeters',
+ *           'symbol'   => 'mm',
+ *           'factor'   => 0.001,
+ *           'kind'     => 'length',
+ *           'source'   => 'http://physics.nist.gov/Pubs/SP811/contents.html',
+ *       )
+ *
+ * To this format:
+ *   'length_millimeter' => Array
+ *       (
+ *            // Short name ( ~ 1 word if possible).  
+ *            'shortname' => 'mm',
+ *      
+ *            // Full name, e.g. several words describing unit.
+ *            'fullname' => t('millimeter'),
+ *
+ *            // Symbol of unit, or abbreviation.
+ *            'symbol' => 'mm',
+ *      
+ *            // Machine-readable name of the category of unit. Serves for storing 
+ *            // category internally.
+ *            'category_id' => 'length',
+ *      
+ *            // Name of the category of unit. Serves for grouping up similar unit 
+ *            // types e.g. in UI.
+ *            'category' => t('length'),
+ *      
+ *            // Decimals. The number of digits to the right of the decimal point.
+ *            // Note: this is just recommended value. It's not enforced in Units 
+ *            // module.
+ *            'decimals' => '0',
+ *        )
+ *
+ * @return 
+ *  Array of arrays of unit definitions, with unit ids as keys.
+ * 
+ * @see hook_define_units()
+ */
+function unitsapi_define_units() {
+  $unitsapi_units = unitsapi_get_units();
+  $units = array();
+  foreach ($unitsapi_units as $unit_name => $unit) {
+    $units[$unit['kind'] . '_' . $unit_name] = array(
+      'shortname'   => $unit['symbol'],
+      'fullname'    => t($unit['singular']),
+      'symbol'      => $unit['symbol'],
+      'category_id' => $unit['kind'],
+      'category'    => t($unit['kind']),
+      'decimals'    => '0',
+    );
+  }
+  return $units;
+}
+
+/**
  * The API call for all unit conversions.
  *
  * @param $value
