Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I implement this hook, I end up with 'en', when everywhere else it's 'und'
It seems like the problem is coming from line 1252 in field_collection.module, the FieldCollectionItemEntity/Entity's view function is being invoked without passing on the $langcode as an argument.
If I change:
$element[$delta]['entity'] = $field_collection->view($view_mode);
to:
$element[$delta]['entity'] = $field_collection->view($view_mode, $langcode);
It fixed my issue, although I don't know if this behavior is on purpose, and whether this change has further implications...
Thoughts?
Comment | File | Size | Author |
---|---|---|---|
#5 | implementing-2042015-5.patch | 1.38 KB | BramDriesen |
|
Comments
Comment #1
-enzo- CreditAttribution: -enzo- commentedI found the same issue the funciton view of Class FieldCollectionItemEntity don't detect the current language if isn't set, as you can see in the following code
Comment #2
BramDriesenThis issue still persist in the latest beta, I suggest patching the $langcode param.
Comment #3
BramDriesenPatch attached and ready for review.
Comment #5
BramDriesenI re-created the patch since I did the diff from the master branch instead of the other way around.
Comment #6
BramDriesenComment #8
jmuzz CreditAttribution: jmuzz commentedThanks for the patch @BramDriesen.
I think this was an accidental omission.
Comment #10
minorOffense CreditAttribution: minorOffense at Coldfront Labs Inc. commentedThis commit actually breaks language detection in some cases. Looks like $langcode has the wrong value so Drupal isn't auto detecting language anymore. It's always using the default value.
Not sure if this is an issue for field collections but this definitely breaks language detection on a client site of ours.
Comment #11
Daniel KorteI agree with @minorOffense. This patch breaks language detection in field collections for me as well.
Comment #12
BramDriesen@Daniel Korte Create a new issue linked to this one. Commenting on a closed issue won't get it fixed :)
Comment #13
Daniel KorteAdded #2888517: Language detection is broken in 7.x-1.x-dev