Hi all,

involved modules:

  1. Views 7.x-3.5
  2. i18n 7.x-1.7
  3. entity translation 7.x-1.0-beta2

Step to reproduce:

  1. Create a content type, enable "Multilingual support" using "Enabled, with field translation" option.
  2. Make only the body field translatable for this content type
  3. Create some nodes for this content type:
    - Node A: choose "English" as source language
    - Node B: choose "English" as source language
    - Node C: choose "Italian" (or any other language you have) as source language
    - Node D: choose "language neutral"
  4. Translate the body field only for Node A and Node C
  5. Create a View that lists those nodes:
    - Add field "content: title" and check "Link this field to the original piece of content"
    - Add field "content: path"
    - Make sure that field language is setted to "Current user's language" in advanced settings
    - Notice that I don't want filter results per language, all nodes have to be listed, regardless of language

Views results:
Viewing the site in ENGLISH, the view shows:

  1. Record 1: (the node that as ENG as source lang, and body translated in ITA)
    -Node A title linked to "mysite/en/node-A-alias"
    -Node A path: "mysite/en/node-A-alias"
  2. Record 2: (the node that as ENG as source lang, and NOT translated in ITA)
    -Node B title linked to "mysite/en/node-B-alias"
    -Node B path: "mysite/en/node-B-alias"
  3. Record 3: (the node that as ITA as source lang, and body translated in ENG)
    -Node C title linked to "mysite/it/node-C-alias" -> Error: should be "mysite/en/node-C-alias"
    -Node C path: "mysite/en/node-C-alias"
  4. Record 4: (the node that as LANGUAGE NEUTRAL as source lang)
    -Node D title linked to "mysite/en/node-D-alias"
    -Node D path: "mysite/en/node-D-alias"

Viewing the site in ITALIAN, the view shows:

  1. Record 1: (the node that as ENG as source lang, and body translated in ITA)
    -Node A title linked to "mysite/en/node-A-alias" -> Error: should be "mysite/it/node-A-alias"
    -Node A path: "mysite/it/node-A-alias"
  2. Record 2: (the node that as ENG as source lang, and NOT translated in ITA)
    -Node B title linked to "mysite/en/node-B-alias" -> Error: should be "mysite/it/node/[nid]"
    -Node B path: "mysite/it/node/[nid]"
  3. Record 3: (the node that as ITA as source lang, and body translated in ENG)
    -Node C title linked to "mysite/it/node-C-alias"
    -Node C path: "mysite/it/node-C-alias"
  4. Record 4: (the node that as LANGUAGE NEUTRAL as source lang)
    -Node D title linked to "mysite/it/node-D-alias"
    -Node D path: "mysite/it/node-D-alias"

Results analysis:

  1. As you can see, "content:path" field is the only result always correct between languages
  2. Instead "content:title" link seems to point always to the SOURCE LANG path, regardless of the current language.

Actual workaround:
Uncheck the "Link this field to the original piece of content" option for title field, and do a rewrite of this field as a link, choosing [path] token as href.

Is this a bug or I'm missing something?

Thank you very much

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MXT’s picture

No response on this yet? I think this is a issue that can't be underestimate...

dawehner’s picture

Feel free to hang out in the issue queue and answer all the questions.

In general i'm really not sure whether your behavior is the expected one, or how views could do something here.
Field translation is a contrib module, so views will not automatically integrate with that one.

What views does is to check out the language of the content, which sort of refers to the language defined by the translation module, not entity_translation. Maybe we would have to figure out how url() fixes this particular problem but in general it seems to be a doable question.

MXT’s picture

Thank you very much for your answer dawehner,

Field translation is a contrib module, so views will not automatically integrate with that one.

At the moment yes, but both Views and Entity Tranlastion will be in Drupal 8 core, so I think is already time to put the right attention since now to the issue.

Then, it can be considered an inconsistency the fact that "content: path" field gives a different result from "content: title (linked)" in the same record?

liquidcms’s picture

i am not sure if this is related; but similar much more basic issue:

- for a node type which is NOT enabled for multilingual support.
- add a "content: title" field in views
- select "Link this field to the original piece of content"

the url for this becomes /en/[title]

when the site is switched to FR, the url remains as /en/[title] when it should be /fr/[title]

i had expected Views did the "right thing" here so have this all over a site of ours. my solution has been to go through all views and add nid field and rewrite this as [title] output as a link and set link path to node/[nid]; this then does the right thing.

pretty sure this would need to be considered a bug and i will likely look in to fixing it as it will be quicker than changing all the views i have on this site. if this is no way related to this issue; let me know and i will open a new issue.

liquidcms’s picture

looking at the render_link function in views_handler_field_node.inc the language is pulled from this line:

$language = $this->get_value($values, 'language');

but this pulls the node_language; which is the language the node is defined in, which for node types which are not being translated; this is the Drupal base language (EN). this isn't correct. we should be pulling the site language here.

as a quick test i forced $language = 'fr' here and this mostly works. my url is now /fr/node/[nid] which does take me to the correct page (my language neutral node; but with the site in FR). but what i was hoping for was a url of /fr/[title]. this seems as though it would be a bug in the Global Redirect module as it should not allow me to go to node/[nid] if there is an path alias (and if i enter the url as /en/node/[nid] sure enough global redirect does the right thing and switches me to /en/[title])

so i am sure there is a bug in the Views handler here but i would bet not as simple as setting language to the site language. there likely needs to be a check if the node is actually language neutral and then set it to site language.

also, more as a question, a view has a setting for "Field Language" with options including "current user's lang" as well as "Language neutral". neither of these help this situation.

liquidcms’s picture

Issue summary: View changes

Removed some
for increase legibility

pingwin4eg’s picture

Title: i18n issue: field "content: title" linked to node doesn't respect current language. "content: path" does instead. » i18n issue: field "content: title" linked to node doesn't respect current language while building URL
Version: 7.x-3.5 » 7.x-3.x-dev

I don't think there should be any check if the node is actually language neutral or not. All this check is already a job of translation modules. As we can see in views_handler_field_node_link.inc (field "Content: Link" which as "Content: Path" works nicely) there is no code about language. So removing it from views_handler_field_node.inc would be convenient solution in my opinion.

pingwin4eg’s picture

Try this quick fix.

nbuonin’s picture

There's a module for this. Try using Internationalization Views

First enable module. Then, when building your view, use the field called "Entity Translation: Title", rather than "Content: Title".

Graham Leach’s picture

(cross-posted because I am not sure where this issue lies, forgive me if this breaks a policy somewhere)
https://www.drupal.org/node/866170#comment-10352693

Hmmm,

The Link this field to its node feature does NOT work with a Multi-Lingual Drupal 6, Ubercart 2 implementation.

The URL for the targets that feature the Link this field to its node work correctly where they are available, i.e.:

  • Content: Image
  • Node: Title

With these, I get what I want and translation works properly:

English:
http://holisticpethelp.com/products/nose-it-k-9-ball-flex-red

Chinese:
http://holisticpethelp.com/zh/products/nose-it-k-9-ball-flex-red

But where this option is NOT available and when trying to link the BODY of the content associated with this product manually, things break down:

A) Include Node: Path, Exclude from Display checked
B) Include Node: Link, Exclude from Display checked (just for safety)
C) Customize Node: Body to reference [path] when Output this field as a link is checked

Will give you the following URL linked to the Node: Body text:

http://holisticpethelp.com/zh/zh/products/nose-it-k-9-ball-flex-red

A) Where in the core code for VIEWS is this happening?
B) Can anyone suggest a fix?

UPDATE! HERE'S A WORKAROUND:

Add Node ID to selected fields
1) Add Node: Nid to selected fields
2) Re-position Node: Nid to top of fields

Configure and link desired display information (in my case Node: Body)
3) Check "Output this field as a link"
4) In Link path:, enter node/[nid]

Toki’s picture

Thanks Graham, your workaround works perfectly. The issue is still present (Views 7.x-3.13). With node/[nid] as a new output, Views transforms the path with the correct language prefix and the pathauto pattern, for example.

knalstaaf’s picture

Status: Needs review » Reviewed & tested by the community

#7 seems to do the job.

Status: Reviewed & tested by the community » Needs work