Entity API provides an entity wrapper which would be an ideal base class for the translation handler class. Class names and method signatures should follow Entity API's conventions to be more consistent.

Comments

Additionally we should define the language property for any entity not having it. This guarantees a better integration with the Title project that relies on the language property to handle language-aware fields.

This might conflict with CTools integration and might not be actually needed, need to ponder about it.

Priority:Major» Normal
Status:Active» Postponed
Issue tags:-D7 stable release blocker

Since entity_language() is going to be introduced in core, I don't think this is needed anymore at the moment.

Component:Code» Base system
Status:Postponed» Active

I seem to have come across an issue with entity_translation & entity_metadata_wrapper and I was hoping anyone else had an idea.

Whenever we attempt to retrieve fields via entity_metadata_wrapper the value of the fields are always returned in the default language instead of the current display language.

After digging around I noticed on these entities(I believe this also occurs with nodes) that with the entity's full view page the language of the entity is always set to the default and that the language specific content would not be retrieved until field_attach_view() which populates $display_language using field_language() and indeed is displaying the expected language versus the default entity language. This seems fine when viewing an entity, however, it seems that entity_metadata_wrapper doesn't load content this way and will never returned the display language as field_attach_view.

To replicate:
- Assumes you have a translatable entity w/ multiple languages.
- Create an entity with a default language(any)
- Create a translation for the newly created entity.
- Next load the entity and pass to entity_metadata wrapper on a translatable page. (The current entity's view is fine)
- Get the value of a field using entity_metadata_wrapper (entity_metadata_wrapper('MY_ENTITY', $entity)->title->value())
- You should notice that the value never changes despite changing languages for the current page.

I am not really sure how this can be addressed, any direction would be most helpful.

Thanks,

Jonathan

I think you can adjust the language of the value being returned via the language() method. Something like this:

entity_metadata_wrapper('MY_ENTITY', $entity)->language('de')->title->value()

Yes this works, however, isn't it expected that the correct corresponding language would be used automatically without having setting it manually?

Status:Active» Postponed

@grndlvl:

What you are proposing is something that should be part of the Entity API module, although I'm pretty sure @fago won't agree on defaulting to the current content language (personally I wouldn't). This issue is about exploiting the EMW as a base for our translation handler, which won't happen at least in the 1.x branch. Not sure whether we will ever have a 2.x branch, however I'll mark this postponed again for now, instead of just wontfixing it.

If you open a new issue in the Entity API queue please link it here, I'd be interested in following the discussion.