API page: https://api.drupal.org/api/drupal/modules%21filter%21filter.api.php/func...

The documentation for function callback_filter_process indicates that the fourth parameter for this function $langcode and that it will tell you "The language code of the text to be filtered."

I have set up a multilingual site. I have made sure that every node of my site is tagged with a specific language. (E.g. "en" for English", "es" for Spanish, etc.). There are no nodes tagged with the language code "und" for undefined on my site.

However, the value of $langcode passed into this function is always 'und' (undefined) no matter what language is set for the node holding the text to be filtered.

Comments

jhodgdon’s picture

Status: Active » Fixed

How to use the parameter is up to your filter -- if your filter needs to do different things based on the language of the text, then you need to code that in your callback. If your filter is language-independent, you can ignore it. I don't think we need documentation of this... and 'und' probably means you do not have a multilingual site or the text you are filtering is not translated? If not that is a separate issue.

If you need further programming support, please use a different channel for requesting it. This is not a support channel. Click "Support" in the header of drupal.org to find support options. Thanks!

gisle’s picture

Issue summary: View changes
Status: Fixed » Active

@jhodgdon,
did you test whether your answer makes sense on an actual multilingual site?

I am writing a filter for a multilingual site that needs to do different things depending on the language of the text filtered. In my callback, I check the $langcode variable to discover the language of the text. However. if the node is tagged with "es" (for Spanish), the $langcode passed into the callback is not "es", but "und" for undefined. I know how to use this $langcode in the callback for my filter, provided it has the correct value. This is not why I reported this incomplete documentation.

I reported this documentation as incomplete because it does not tell you how to get the correct value passed into the callback. In your reply, you just repeat what the existing documentation say (set up a multilingual site, and make sure your nodes are tagged with language codes that indicate what language the text is). However, if one acts on this documentation, one discovers that this not how it actually works. Hence, the documentation is wrong or incomplete.

That is why I report this as documentation problem.

Please do not think this is as programming support. The problem is not with programming, but with the documentation not telling you how to set up the use of this callback function on a multilingual site to get sensible values passed into the callback through the $langcode parameter.

I don't think this documentation is "fixed".

gisle’s picture

Category: Support request » Bug report

Changing the category to "Bug report" since the choice of the category "Support request" clearly caused a misunderstanding. And to avoid further misunderstanding: The "bug" reported here is in the documentation, because the documentation does not explain how a developer of a multilingual site can set up the callback to get a useable value passed into the callback by means of the $langcode parameter.

jhodgdon’s picture

Component: documentation » filter.module

OK, this is not a documentation bug. Changing component to avoid further misunderstanding. If the language is not being passed in, that's a problem that documentation cannot fix. Unsubscribing also... I'm the docs maintainer.

gisle’s picture

Title: How is parameter $langcode supposed to work? » callback_filter_process $langcode parameter is always "und"
Issue summary: View changes