function hook_language_negotiation_info

hook_language_negotiation_info()

Define language negotiation providers.

Return value

An associative array of language negotiation provider definitions. The keys are provider identifiers, and the values are associative arrays defining each provider, with the following elements:

  • types: An array of allowed language types. If a language negotiation provider does not specify which language types it should be used with, it will be available for all the configurable language types.
  • callbacks: An associative array of functions that will be called to perform various tasks. Possible elements are:
    • language: (required) Name of the callback function that determines the language value.
    • switcher: (optional) Name of the callback function that determines links for a language switcher block associated with this provider. See language_switcher_url() for an example.
    • url_rewrite: (optional) Name of the callback function that provides URL rewriting, if needed by this provider.
  • file: The file where callback functions are defined (this file will be included before the callbacks are invoked).
  • weight: The default weight of the provider.
  • name: The translated human-readable name for the provider.
  • description: A translated longer description of the provider.
  • config: An internal path pointing to the provider's configuration page.
  • cache: The value Drupal's page cache should be set to for the current provider to be invoked.

See also

hook_language_negotiation_info_alter()

Related topics

File

modules/system/language.api.php, line 140
Hooks provided by the base system for language support.

Code

function hook_language_negotiation_info() {
  return array(
    'custom_language_provider' => array(
      'callbacks' => array(
        'language' => 'custom_language_provider_callback',
        'switcher' => 'custom_language_switcher_callback',
        'url_rewrite' => 'custom_language_url_rewrite_callback',
      ),
      'file' => drupal_get_path('module', 'custom') . '/custom.module',
      'weight' => -4,
      'types' => array('custom_language_type'),
      'name' => t('Custom language negotiation provider'),
      'description' => t('This is a custom language negotiation provider.'),
      'cache' => 0,
    ),
  );
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!language.api.php/function/hook_language_negotiation_info/7.x