How to call functions from another module in hook_language_negotiation_info()? I am writing a new custom module which is dependent on geoip module. I'm trying to add another language negotiation in the language detection configurations which would trigger a callback function defined in the module. Now How do I call the function defined in geoip.module file? I tried calling the function directly and after a module_load_include and both do not work.

/**
 * Implement hook_language_negotiation_info
 */
function my_module_language_negotiation_info() {
  return array(
      'geoip_language_provider' =&gt; array(
          'callbacks' =&gt; array(
              'language' =&gt; '_my_module_language_callback',
          ),
          'file' =&gt; drupal_get_path( 'module', 'my_module' ) . '/my_module.module',
          'weight' =&gt; -4,
          'name' =&gt; t( 'My Module GeoIP Negotiation Provider' ),
          'description'=&gt; t( 'This redirects the user to correct language based on their IP.' ),
          'cache' =&gt; 0,
      ),
  );
}

function _my_module_language_callback() {
  module_load_include( 'module', 'geoip' );

  //Returns array of languages based on country code. Eg. array( 'CN' =&gt; 'zh-hans',)
  $languages = _my_module_language_mapping();
  $country_code = geoip_country_code();
  $default_langcode = language_default( 'language' );

  if( !isset( $languages[$country_code] ) ) {
    watchdog( 'geoip_language', 'The country code is not in the language mapping.' );
    return $default_langcode;
  }

  return $languages[$country_code];
}
Not sure if this is the correct reason for this behaviour or not but it seems like the language negotiation process runs before the modules and the themes are bootstrapped in Drupal which would explain why the function is not available by default.

Changed the module_load_include to actually include the file directly by calling drupal_get_filename and requiring the file and it worked.

function _my_module_language_callback() {
  $geoip_file = drupal_get_filename('module', 'geoip');
  if( file_exists( $geoip_file ) ) {
    require_once DRUPAL_ROOT . DIRECTORY_SEPARATOR . $geoip_file;
  }

  $languages = _my_module_language_mapping();
  if( function_exists( 'geoip_country_code' ) ) {
    $country_code = geoip_country_code();
  }
  $default_langcode = language_default( 'language' );

  if( !isset( $country_code ) ) {
    watchdog( 'geoip_language', 'Country Code could not be identified by IP.' );
    return $default_langcode;
  }

  if( !isset( $languages[$country_code] ) ) {
    watchdog( 'geoip_language', 'The country code is not in the language mapping.' );
    return $default_langcode;
  }

  return $languages[$country_code];
}