Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I enabled 3 languages on my site. When I use the views module "i18n: Content negotiation" I do not get what I expect when using "Mixed current language" in the Administer / Site configuration / Languages / Languages
If I set it to Only current language for example, it does work and I only see current language. When I use the mixed "Mixed current language" option, I see the current language + default language also if a current language translation exists. I should only see the current language in that case.
I'm not sure this is a views problem or a problem of this module.
Comments
Comment #1
JGO CreditAttribution: JGO commentedNot anyone who can help me with this ?
----------------------------
JGO | http://www.e2s.be
----------------------------
Comment #2
keon CreditAttribution: keon commentedI can not help - i don't get that far even (error while adding the filter),
but it would be great if it does work like you say,
then maybe we can avoid having to clone each view for the extra languages !
Comment #3
keon CreditAttribution: keon commentedmaking the view again helped me to get rid of the error i had earlier, now it works as you discribed,
but correctly, only 1 item is shown: handy, now just make the menu-item in the 3 languages pointing to the same path ...
succes!
Comment #4
JGO CreditAttribution: JGO commentedI still have the problem:
This is the query it builds in my case (which looks clearly wrong):
When set to site default language (probably ok)
SELECT node.nid AS nid
FROM node node
LEFT JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN term_data term_data ON term_node.tid = term_data.tid
WHERE (term_data.vid in ('8'))
AND (node.language ='en' OR node.language ='' OR node.language IS NULL)
When set to nl seems wrong:
SELECT node.nid AS nid
FROM node node
LEFT JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN term_data term_data ON term_node.tid = term_data.tid
WHERE (term_data.vid in ('8'))
AND (node.language ='nl' OR node.language ='en' OR node.language ='' OR node.language IS NULL)
It should be only showing the en if there is no node found in the current language
EDIT:
A quick (but prolly dirty fix) is modifying the following inside i18n.module
The problem is actually that the vocabulary is a localizable one in the site's default language (en)
So it finds also nodes associated with it in other languages.
So a node can be translated and being related to the same vocabulary.
----------------------------
JGO | http://www.e2s.be
----------------------------
Comment #5
cels CreditAttribution: cels commentedThis issue is a logic/config problem with all the i18n system.
The best would a option check for control the logic:
A) Do you display ALL the languages of the nodes?
b) Do you display the current language if the node have the translated version?
If not, the i18n_db_rewrite_where should be changed with the **correct** behavior (don't mix the node's translates).
Related:
multilingual views like i18n's "Mixed current language (if available) or default language (if not) and language neutral."
#337089: Mixed mode ultra slow on large db
Comment #6
hiwilson CreditAttribution: hiwilson commentedI have the same problem as JGO and I implement his code. However, if there is a node with current language only, then all language neutral item will disappear. I rearrange JGO's code to solve this problem.
from:
return "$alias.language ='$current' or (($alias.language ='$default' OR $alias.language ='' OR $alias.language IS NULL) AND NOT exists(select * from $alias sub where $alias.tnid = sub.tnid and sub.language = '$current') )";
to:
return "$alias.language ='$current' OR (($alias.language ='$default') AND NOT exists(select * from $alias sub where $alias.tnid = sub.tnid and sub.language = '$current') ) OR $alias.language ='' OR $alias.language IS NULL";
Comment #7
gedvan CreditAttribution: gedvan commentedBoth codes above do not support table prefixes. I rewrote JGO and hiwilson's code to:
Works for me.
* Sorry my english...
Comment #8
JGO CreditAttribution: JGO commentedThere was another bug, changed the code to:
I added AND $alias.tnid <> 0
As long as there exist no translation at all, the tnid = 0. So the subclause would always return true if a node is created in another language but not translated.
Normally the nodes should always be first created in the main language, but better catch the case where it's created first in another language too!
----------------------------
JGO | http://www.e2s.be
----------------------------
Comment #9
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedwouldn't it be possible/faster to use the mysql "find_in_set" function and order on that and then group by tnid?
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_fi...
then all you need to do is make a prioritized ordering of the languages
Comment #10
abaddon CreditAttribution: abaddon commentedsame as above, but i was having a problem with forums displaying both default and current language on /forum
i dont understand the {{$alias}} notation, for me $alias was "t", it failed but the below worked, im using prefixed tables too
might help someone..
(edit: some typos :-)
Comment #11
JGO CreditAttribution: JGO commentedYep I hope someone will implement this properly soon.
This should have been working for long long time :|
----------------------------
JGO | http://www.e2s.be
----------------------------
Comment #12
Sylvain_G CreditAttribution: Sylvain_G commentedsubscribe
Comment #13
klonosI do not see any 'i18n: Content negotiation' filter in my view. Some thing I am missing here?
views 6.x-3.x-dev (2010-Mar-26)
i18n 6.x-1.x-dev (2010-Apr-01)
Comment #14
Sylvain_G CreditAttribution: Sylvain_G commentedIt as moved to node:Content negociation
Comment #15
klonos...actually it is in 'Node translation: Content negotiation' but thanx for the heads-up.
To get what I was looking for to work, I used the viewfield module to 'embed' my views in nodes and then used translation.
Comment #16
Jose Reyero CreditAttribution: Jose Reyero commentedMoved to new project. See #788290: Fix views compatibility issues (2.x, 3.x), spin off i18nviews module?
Comment #17
kasiawaka CreditAttribution: kasiawaka commentedI want to confirm that the solution presented in #8 works on Drupal 6.15 with Views 6.x-2.10 and i18n 6.x-1.5
To capture all the information in one place:
Goal
Use views to display the multi-lingual content as per website Language settings (admin/settings/language/i18n) that are set to
In my example, I have English and French content. English is a default language. Not all the content is translated to French so Views should display the content the user selected language but if any node is not available in that language, show the content in the default language (in this case English).
Problem
Internalization (i18n) module has Views filter "i18n: Content negotiation" that is suppose to "Removes the nodes that are not valid according to the content selection mode".
Unfortunately, this is not working correctly because when viewing the page in French, both French and English nodes were displayed although there were a translation of each other and only French nodes should be visible because they existed.
Solution
Thanks to the posters in this thread, the solution is: modify the file i18n.module (i18n module root directory) by modifying the function i18n_db_rewrite_where
Replace
with
Comment #18
JGO CreditAttribution: JGO commentedIndeed, if now somebody implements it properly into the module that would be great!
Comment #19
kirie CreditAttribution: kirie commentedI've also tested the summary given in #17 and works well so far. Should we move this issue over to the i18n queue - as that is module being patched?
Comment #20
Danny EnglanderSubscribing
Comment #21
kasiawaka CreditAttribution: kasiawaka commentedUsing the solution from #17 (thanks to all previous contributors), I've created a patch for i18n module: http://drupal.org/node/887116
Please test it and post comments that the i18n thread, where the patch was supplied.
Comment #22
YK85 CreditAttribution: YK85 commentedI was wondering if there may have been further development? Thank you
Comment #23
miro_dietikerRecheck
#887116: Views filter "i18n: Content negotiation" is not working properly for "Mixed current language (if available) or default lang ..."
And report current state. As Jose said, in D6 is a huge risk of regressions and we should try to address it in D7 as early as possible.