When managing multilingual content with Entity Translation, there's currently no possibility to filter out entities that have no ET in the current display language in views (please correct me if i'm wrong here!).
Therefore, i'm planning to implement (and contribute via patch) a views filter that filters the selection of entities in views for selecting only entities that have a original version or translation in the current display language.
The filter selects only entities, which:
* have their original language version matching the current display language
* have an entity_translation record matching the current display language
* are language neutral (controllable via switch, see below)
Also several advanced settings switches are planned:
* switch to include or exclude language-neutral entities
* switch to override filter for admins (via current user's permission)
* switch to filter out unpublished translations (entity_translation.status = 1)
* switch to filter out stale translations (entity_translation.translate = 0)
Now my questions:
1.) Is the problem analysis right?
2.) Does the proposed solution make sense at all?
3.) Is there any other work on this problem already doen or in progress at the moment?
4.) What idea, suggestions or general input do you have?
I'm starting on this right away, so don't hesitate with your input ;)
cheers and thanks,
daniel
Comments
Comment #1
plachThis sounds all good, I'm not aware of any other effort in this direction so feel free to proceed with your plan :)
Thanks!
Comment #2
giorgoskI suppose you show this #1330332: Entity translation: Views field language filter after you started this issue
this proposal seems all good
I would be willing to test the patch if time permits
thanks
Comment #3
danielnolde commentedA first shot for an Entity Translation language filter is implemented via hook_query_alter in this simple sandbox module:
http://drupal.org/sandbox/daniel.nolde/1404374
The aim is to drive this towards a first generally appropriate solution fast within this sandbox module and then ideally to move the code over to Entity Translation itself.
There are currently a lot of possible improvements.
First in line:
* The fields are given in the query conditions in a very dirty way - because the proper, documented way (just using the field alias returned by the queries' addField method) throws SQL Exceptions galore (Database API wisdom desperately needed here! <:)
* Let's discuss whether this is the correct problem, the proper solution and the right direction to move in, or whether we should instead (or additionally?) do this via a explicit views filter (would work only for views, though).
Then: TODOS
* Add configurable options:
* switch to selectively include or exclude language-neutral entities
* switch to override filter for admins (via current user's permission)
* switch to filter out unpublished translations (entity_translation.status=1)
* switch to filter out stale translations (entity_translation.translate=0)
* Add dedicated and explicitely addable views filter to do the same job
selectively applicable for each view display
* entity_translation_filter_query_alter
* consider and test broader application of rewriting beyond just views
* make conditional statement "$base_table == 'node'" for triggering rewrite
generic and entity type agnostic, by somehow (?) making a connection
between the queries' basetable, the associated entity type, and
ET's translation support for that specific entity type. puh.
* cache $base_field determination
* get rid of necessary but very dirty workaround in language conditions:
tablealias.fieldalias / tablealias.fieldoriginalname
* make status=published on translations automatically matching a
status=published condition of (known) base table(s)
Get involved! Seize the module's issue queue at: http://drupal.org/project/issues/1404374?categories=All
Comment #4
danielnolde commentedComment #5
kristen polComment #6
kristen pol"Views" was added back into the title because that is what the issue summary is about. If you are choosing to do a more generic solution that extends beyond views, it would be good to update the summary with the current focus of the issue.
Thanks!
Kristen
Comment #7
fabsor commentedI created an alternate approach, #1524210: Expose entity translation table to views, that exposes the entity translation table and adds a relationship to each entity table. The main idea was to expose the actual table so you could create a UI for translators, but you can also filter out content that has a particular translation.
The approach described above would be more of an automatic approach though, so maybe they can co-exist.
Comment #8
plachAny progress on this?
Comment #9
fabsor commentedI discussed this with danielnolde some time back, and we concluded that this is no longer necessary with the more extensive views integration already commited.
Comment #10
Yuri commented@fabsor or anyone else aware of this issue:
#9 suggests that "this is no longer necessary with the more extensive views integration".
May I ask what specific views integration takes care of this issue?
I have all latest dev versions installed, but still can't filter in views by entity translation language.
If you have any guidelines, please share. Thanks
Comment #11
fabsor commentedYou can add a relationship to the entity translation table, and from there you can add entity translation: language as your filter. This filters out entities on a specific language.
Comment #12
plachComment #14
farse commented@fabsor that is an amazing snippet of information that has solved the problem I was having.
Comment #15
farse commentedOne other thing... this might be cause for a new issue.. but what about Views for search (Search API with solr backend I'm using)? Just checked and only 'indexed node' things seem to be available for use in relationships, thereby back to the same problem as before..
i'm using the search_api_et module as well.
Comment #16
BParticle commentedAny news on this? I am trying to show a view of indexed nodes through Search API with a translated body field. The Relationship is indeed missing here, and when I use the usual language filter my view is empty.
Comment #17
liquidcms commentedi'll go ahead and re-open this one as well.. as per #11 above:
relationship: Content: Entity translation: translations
filter: (Translations) Entity translation: Language (= Danish)
field language: Current user's language (which would be english while running Views preview; but guessing overridden by filter??)
what i set for filter language has no impact on language of output (it is always English version).
without filter (the path for this page view is set to json/data):
en/json/data -> gives English data
da/json/data -> gives Danish data
Comment #18
wimpie3 commentedSame problem as #17
Comment #19
norman.lolI needed to ensure that only nodes in A) the current language and B) published translations show up in a view. Here is how I fixed it from a custom module: