API page: http://api.drupal.org/api/drupal/modules%21system%21language.api.php/fun...

The problem:
The documentation for hook_language_negotiation_info indicates these callback options:

callbacks: An associative array of functions that will be called to perform various tasks. Possible elements are:
negotiation: (required) Name of the callback function that determines the language value.
language_switch: (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.

But the examples use differently keyed callbacks:

      'callbacks' => array(
        'language' => 'custom_language_provider_callback',
        'switcher' => 'custom_language_switcher_callback',
        'url_rewrite' => 'custom_language_url_rewrite_callback',
      ),

The same problem is in this documentation as well: http://api.drupal.org/api/drupal/includes%21language.inc/group/language_...

Comments

neRok’s picture

Title: hook_language_negotiation_info callback array specification inaccuracy » hook_language_negotiation_info Callback keys dont match documentation
Component: language system » documentation

Just moving to the correct 'component' for the API doc people to see.

jhodgdon’s picture

Issue tags: +Novice

Thanks for reporting this! Given that the core implementation of this hook matches the example function body for hook_language_negotiation_info(), I think the example is correct and the documentation is incorrect. See:
https://api.drupal.org/api/drupal/modules!locale!locale.module/function/...

So, what we need done for this issue:
a) Update the documentation block for hook_language_negotiation_info() so that the callbacks section matches what is in the example function body.
b) Update the code sample in
https://api.drupal.org/api/drupal/includes!language.inc/group/language_n...
so that it is correct also in the callbacks section.

Sounds like a good Novice project... and this is a 7.x problem only. In 8.x the documentation and the actual code match. Probably what happened is that an 8.x documentation patch got ported to 7.x without someone noticing these array keys had changed in 7.x (oops!).

ebargtuo’s picture

Status: Active » Needs review
StatusFileSize
new2.19 KB

Here's a patch for this. I hope it helps.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

That looks good, thanks!

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks again! Committed to 7.x.

Automatically closed -- issue fixed for 2 weeks with no activity.