This is a great module, it is very nicely written. I am currently doing a multilingual site using entity translated nodes and ran into some issues with getting advanced polls to translate. In looking at the code some support was there for translations but it seemed a bit off so I am not sure that entity translation support is actually a supported feature - which is why I am opening this as a feature request.

I have a patch which seems to work, although I think it could use some work - specifically in the advpoll_get_data function where it tries to look for language fields and falls back to 'und'. I added some code specifically to handle the 'choices' field because this is really the only one that needs to be translatable, but there is nothing to prevent users from making a mistake and setting other fields to translatable.

The nice thing about entity translation is that the poll results are aggregated across both languages automatically since it is a single node. One other fairly major change I needed to make was to index the choices with choice_id and not the text so that the comparisons in advpoll_voteapi.inc are language agnostic.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joel_osc’s picture

Hope the community can help clean this patch up...this is a great module - it would be awesome to have fully entity translation support.

joel_osc’s picture

Status: Active » Needs review
FileSize
5.23 KB

Slight change to make the results show up properly translated.

spotzero’s picture

The provided patch in #2 did not apply cleanly to the 7.x-3.x branch.

I've fixed the problems, and the attached patch applies for me.

airstarh’s picture

Thank you very much! It helps me!
Actually
advpoll_entity-translation-2025913-2.patch - helped. But stop working after D7 core update or Entity Translation update.
Then I googled again and saw
advpoll_entity-translation-2025913-3.patch
It helped again.
Could you know if it would work after the next D7 or ET update?
Thanks anyway!

Echofive’s picture

Hi,

The patch "advpoll_entity-translation-2025913-3.patch" won't work for me.
When I apply it, I get some errors when I try to edit an existing node or its translation.

joel_osc’s picture

Can you post the errors? I have it working on a production site, so I assume the errors won't be too hard to fix.

Offlein’s picture

Issue summary: View changes

This seems to be working perfectly on our site.

Offlein’s picture

Status: Needs review » Needs work

Actually, no, I take that back. This made it so unlimited voting stopped working and so I couldn't produce any new Advanced Polls without getting an error about including 2 options and about how one choice is required. I'll look into what could be causing this...

Offlein’s picture

Status: Needs work » Needs review
FileSize
5.38 KB

OK, the previous patch worked just fine when editing existing nodes, but would fail on new ones because (for reasons not 100% clear to me) new node forms all produce undefined language elements that have the language applied later. The thing was attempting to validate 'en' fields as 'en', when the arrays hadn't been changed from 'und' yet.

For what it's worth, I don't actually know if I think this is the right way to handle validation of this. It seems like you're supposed to write an entity translation validation handler. But... On the other hand, I also don't see why this is "wrong", so I can't speak to that.

Here's the new patch which should work for new and existing nodes.

joel_osc’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @Offlein - your patch works well. It would be nice to get this committed at some point soon.

The last submitted patch, 2: advpoll_entity-translation-2025913-2.patch, failed testing.

joel_osc’s picture

tripper54’s picture

tripper54’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Committed, thanks for your work on this!