I'm trying to display in a view all available languages for a node translated with entity translation.

The only way I found to do it is to add a language selector to the entity relationship. If it is the only way I would find useful to add a language selector to the entity translation relationship.

Comments

Status:Active» Needs review
StatusFileSize
new1.88 KB
PASSED: [[SimpleTest]]: [MySQL] 337 pass(es).
[ View ]

Here's a patch that add the language selector

Status:Needs review» Needs work

The patch works fine, but couldn't you just add a filter on entity_translation.language after adding the relationship instance to achieve the same thing? I would like to avoid adding filtering functionality on the relationship if it's not necessary.

Also, a small review:

+++ b/views/entity_translation_handler_relationship.inc 2013-01-15 10:23:42.292210507 +0100
@@ -26,7 +56,10 @@
+    $join->extra[] = array('field' => 'entity_type', 'value' => $def['entity type']);

Instantiate the array before using it ($join->extra = array())

Thanks fabsor for the code and functionality review.

I tried to do what you say : create a relationship with entity_translation and filter this relationship with the language. But it had no effect (or not the one I was expected, I don't remember). Nevertheless, your review make me think that it should have work (I wasn't really sure about that) I have to make some more tests to see where there's something wrong...

OK, here's my use case.
I want to display a views with these rows :

--------------------------------------------------------------------------
| Node Title                                 | Languages                 |
--------------------------------------------------------------------------
| first article translated all languages     | English, Français, Español|
| second article only in english             | English                   |
| troisième article only in french           | Français                  |
| fourth article translated all languages    | English, Français, Español|
--------------------------------------------------------------------------

So I add three relationships with entity_translation for each languages (fortunately I only have three languages)
If I use filter to say to each relation in which language I want it, the rows are these :

--------------------------------------------------------------------------
| Node Title                                 | Languages                 |
--------------------------------------------------------------------------
| first article translated all languages     | English, Français, Español|
| fourth article translated all languages    | English, Français, Español|
--------------------------------------------------------------------------

There's only those that are translated in the three languages.

Now if I use my patch, I have what I want.

I attach, my views exports. The first (views_export-nodes_translations_ok.txt) will only work with my patch, the second, should work without my patch.