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_...
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | hook_language_negotiation_info-callback-keys-documentation-1977054-3.patch | 2.19 KB | ebargtuo |
Comments
Comment #1
neRok commentedJust moving to the correct 'component' for the API doc people to see.
Comment #2
jhodgdonThanks 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!).
Comment #3
ebargtuo commentedHere's a patch for this. I hope it helps.
Comment #4
jhodgdonThat looks good, thanks!
Comment #5
jhodgdonThanks again! Committed to 7.x.