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.
The commit from #2042015: Implementing hook_field_collection_item_view returns an incorrect $langcode causes field collection to not use the proper translation for a field collection.
Comment | File | Size | Author |
---|---|---|---|
#9 | language_detection_is-2888517-9.patch | 1.2 KB | minorOffense |
#2 | language_detection_is-2888517-2.patch | 1.38 KB | amoebanath |
|
Comments
Comment #2
amoebanath CreditAttribution: amoebanath at ComputerMinds commentedAlso running into this issue.
I've got a non-translated fieldcollection field with translated fields, and they're showing in the wrong language when rendered.
For me the original change passes in UND as the language, which sort of makes sense because the fieldcollectionitem is in language UND (it's untranslated), but obviously at the end I want my fields to render in EN/DE/FR/IT. When the langcode isn't passed in the entitycontroller (entity.controller.inc:view()) will get the language from $_GLOBALS['language_content'], which seems to be what I want.
Not really sure how to go about determining whether to pass it through / what to pass through instead...
A starting point might be to undo the change that passes $langcode through.
Comment #3
james.williams CreditAttribution: james.williams at ComputerMinds commentedIIRC, at some point, the entity reference module's formatter had a little setting for choosing whether to use the 'inherited' language that is passed through, or to avoid using the passed one. Something like a checkbox saying 'Use parent content language'. As I believe there is a use case for either approach.
Comment #4
DamienMcKennaSeems like adding some tests would help ensure the functionality works as intended.
Comment #5
DamienMcKennaLets run the tests that already exist.
Comment #6
Chris Matthews CreditAttribution: Chris Matthews commentedThe patch in #2 is a year old, but still applied cleanly to the latest 7.x-1.x dev snapshot.
Comment #7
DamienMcKennaPlease be careful with the tags, it can be easy to accidentally remove them. Happy holidays!
Comment #8
PapaGrandeI can confirm that the patch fixes a client's site with translated fields and 7.x-1.0-beta13.
I'm no expert on writing tests, but I think checkFieldCollectionContent() must be flawed in that it should fail when comparing translations. Perhaps it just needs to be tweaked to better match actual scenarios.
Comment #9
minorOffense CreditAttribution: minorOffense at Coldfront Labs Inc. commentedHere's a reroll for the latest dev.
Comment #11
ram4nd CreditAttribution: ram4nd commentedComment #12
minorOffense CreditAttribution: minorOffense at Coldfront Labs Inc. commentedThanks for committing the fix. Though I don't see how I had a syntax error in the reroll...
Comment #13
DamienMcKennaThe syntax error comes from this line:
It was added in #1063434: Add Feeds integration to FieldCollection.