Views.module is not compatible with i18n

Bahlool - May 26, 2006 - 16:37
Project:Views
Version:4.7.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi,

When the content is listed on a 'page' using the view module, it shows the content of all languages instead of only showing the current language.

Under the 'advanced settings' of i18n i've set the option to "Only current language and no language", but still doesn't work.

would appreciate any help.
thanks.

#1

Alex Schenkman - June 23, 2006 - 21:22

Hi:

Did you find any solution for this?
I have the same problem, =(

Thanks in advance.

#2

merlinofchaos - June 24, 2006 - 01:36

Unfortunately I've had no time to look. I'm not at all familiar with i18n.

#3

fde - July 28, 2006 - 14:05

As mentioned above, the Views module does not filter the nodes by language when the i18n module is enabled. This means that all the nodes from all the languages are displayed, which is not desirable on a multi-lingual site.

The i18n module provides a table 'i18n_node' which maps nodes with their translations. So to know the language of a node we can use:

SELECT language
FROM `i18n_node`
WHERE nid =...

We should still find out what is the current language and then compare the two.

Maybe the author of the i18n module could help.

Hope this can help, it would be really great to have Views working with i18n. By the way, thanks for the great module, I just installed it and apart from this issue it is really remarkable.

Fred.

#4

merlinofchaos - July 28, 2006 - 15:21

Ahhh! In fact, my policy is that information like that from modules must be provided by the module, so i18n needs to supply a filter that people with views can use. Maybe I've been overcomplicating the issues with i18n.

Worst case scenario is that someone could write an i18n module that makes this data available.

#5

David Lesieur - August 10, 2006 - 01:28
Title:Views.module is not compatiable with i18n» Views.module is not compatible with i18n
Status:active» patch (code needs review)

The i18n module usually handles the language filtering through hook_db_rewrite_sql(). I noticed that Views passes 'node' on its db_rewrite_sql() calls, so I edited i18n_db_rewrite_sql() to support 'node' in addition to 'n' as a primary table (see the patch), et voilà! At least it seems to work according to my [very] quick test. Now, should i18n be modified as such, or should Views use 'n' as the primary table in its queries? The Drupal core seems to always use 'n', so should Views do the same?

I don't think i18n should implement Views' hooks. That would force the site's designer to manually take care of the language filtering in each of his views. And more importantly, allowing i18n to automatically do its usual filtering ensures that nodes are filtered in accordance with its sophisticated "Content selection mode" (see administer > settings > i18n > advanced settings).

AttachmentSize
i18n.inc_8.patch410 bytes

#6

canen - August 10, 2006 - 02:33

Subscribing

#7

merlinofchaos - August 15, 2006 - 14:39

Ahh! The reason the views module uses 'node' as the primary table is for consistency. It always uses the full name of the table, and originally it *did* special case 'node' to 'n' but that was very ugly and was causing me problems in debugging.

#8

David Lesieur - August 15, 2006 - 21:35

I'm bringing the ball into i18n's yard. We'll see what happens. ;-)

#9

cgn - September 24, 2006 - 09:12

Hi all,
I am facing the same issue of this thread. I am trying the patch, but I would like to propose to your attention a different solution as well. Why not adding a new filter like "i18n: language"? This might be even a more powerful feature to merge such two important modules.
Thx,

#10

merlinofchaos - September 24, 2006 - 12:34

Such a filture would have to be added by i18n using the views API -- which would undoubtedly be very easy. Could likely add current language and 'by language' rather easily.

#11

merlinofchaos - September 25, 2006 - 03:33
Status:patch (code needs review)» won't fix

Just to be clear, it is the policy of Views to not include support for modules that are not in core.

If a contrib module needs that support, the patch must be submitted to that module, not Views.

#12

hedac - September 29, 2006 - 00:22

then i18n should be a core module for next major drupal release. I think they are working on it.

I think views should have to report only current language or whatever is specified in the i18n settings. if you have a language filter to override it... perfect.. but it makes sense to act by default as the core taxonomy node view for example.

#13

merlinofchaos - October 2, 2006 - 00:14

Uhh, Drupal core doesn't have any language settings for a node; that is completely an i18n module definition. In order for views to be able to act on that, it either needs to properly rewrite the views query OR it needs to export its data to Views so that people using i18n can utilize that data, whichever works better.

In either case, as I said before, it is the policy of Views that, because it makes it possible for all modules to make their data available to Views, it is the policy of Views to only support Drupal Core features and data, and not other modules. Thus I retain and reiterate "won't fix" status.

#14

high1memo - October 7, 2006 - 12:58

I have come across the same problem, as I'm sure many others would have. It seems that for the past 3 months both parties refuse to include the fix in their module considering it the responsibility of the other party. Can anyone recommend a patch so that we can carry on and fix it ourselves? I'm a bit of a newbie so woudlnt know where to begin, but if someone can mention what code to put where I would appreciate it,
cheers,

#15

high1memo - October 7, 2006 - 13:05

I just figured out what to do with the patch file above :P
did i understand correctly, but all that needed to be done is add a "case 'node':" and it works!

#16

merlinofchaos - October 7, 2006 - 16:17

If i18n maintainers won't patch their module to accept 'node' as well as 'n' in their db_rewrite_sql routines, that is both inane and asinine at the same time.

#17

sergiocaridad - October 10, 2006 - 15:25

There should be a standard way of naming tables in queries, so hook_db_rewrite_sql() could be safely implemented by any module (including, but not limited to i18n). I don't know if such a standard exists, but if not, it should. And both modules involved in this (imho kind of stupid) argument should comply to that standard.
So, this is an issue that should be solved in "core drupal api", otherwise this could happen again anytime between any other pair of modules.

#18

merlinofchaos - October 10, 2006 - 19:53

I will insist until the end of the earth that calling the 'node' table 'node' is perfectly valid.

The core Drupal API only cares if the primary field is 'nid' and doesn't care at all what the primary table is.

#19

yched - December 2, 2006 - 18:13
Status:won't fix» fixed

It seems the patch in #5 has been committed in i18n after all...

#20

Anonymous - December 16, 2006 - 18:15
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.