When investigating a bug reported with my module, which provides an input filter, on a sample multilingual site I have set up for that purpose, I've noticed that it seems that $langcode, as passed to filter callback hooks (see the hook_filter_FILTER_process() documentation), is not receiving anything other than LANGUAGE_NONE, even when the node's language menu is most certainly set to something other than "Language neutral."
I tried to investigate this by stepping through the code. The furthest I've got so far is that field_is_translatable() is being called with metadata about the body field (or field instance?) passed as one of the parameters, but at that point, the 'translatable' value in that data is already FALSE. I'm afraid I don't know enough about either the multilingual/translation or the field systems to hazard a guess as to why.
I believe this worked at some point…
Comments
Comment #1
Anonymous (not verified) commentedIs this present in 8.x-dev?
Comment #2
Garrett Albright commentedI don't have a D8 install to play with. I'll look into that over the weekend if I have the time and nobody else beats me to it.
Comment #3
Garrett Albright commentedOkay, I installed D8 and played around with it a bit. Fortunately, porting D7 input filters to D8 seems to be trivial at the moment.
I can confirm that my module's filter callback isn't getting anything for the $language parameter other than 'und' under Drupal 8 as well. (LANGUAGE_NONE is not defined in the D8 codebase anywhere for some reason).
Comment #4
kfritscheThis is the $langcode from the field and not the entity. This is only set if the field is translatable.
For D7 you will need Entity Translation and for D8 there is #1188388: Entity translation UI in core.
In my mind it would be better, if fields would have the language from the entity instead of undefined. Especially for this case it would be useful. Otherwise this parameter is only usable for translatable fields.
@Garrett: In D8 it is now LANGUAGE_NOT_SPECIFIED.
edit: If nothing will be changed, at least we should document this behavior.
Comment #15
larowlan