There's a bug when using i18n taxonomies. The vocabulary is created without a language setting, each term gets a language setting and corresponding terms are 'connected' via the translation option. However, when a new node is created, now terms are shown (even though the vorcabulary is set as 'required' for the node type). This is caused by the taxonomy SQL rewrite in i18n_db_taxonomy_rewrite. $primary_table is set to vocabulary, so i18n adds where v.language = 'xy' to the query. Result: Vocabularies are only shown if they have the 'right' language, but i18n vocabularies have no language set, only the terms have a language. I added the following code to i18n_db_taxonomy_rewrite:
if (preg_match("/INNER JOIN {vocabulary_node_types}/", $query)) {
$result['join'] = "LEFT JOIN {term_data} term ON v.vid = term.vid";
$result['where'] = i18n_db_rewrite_where('term', $mode);
return $result;
}
It fixed the issue and correctly shows the terms that have the 'right' language. I didn't notice any unwanted side issues so far. Could someone please check the patch (for latest version [1.36.2.2] of i18n.module) and work on the code (as this is the first time ever that I write Drupal code)?
Thanks
Wonderland
| Comment | File | Size | Author |
|---|---|---|---|
| i18ntaxonomy.patch | 753 bytes | wonderland |
Comments
Comment #1
jose reyero commentedLet me try to understand it better.
So you have a 'required' vocabulary but it has no terms for some language, is that it?
I so, I think current behavior is more consistent with Drupal's -vocabulary is shown even when it has no terms- and a core patch would be more adequate for that...
Comment #2
wonderland commentedHi Jose,
no, that's not what I'm trying to say :-)
I have a site with two languages, say en and de. And I have a vocabulary, let's call it vocabtest. This vocabulary has no language assigned. vocabtest contains several terms, each term exists twice, once with en language and once with de language assigned. The corresponding terms are "connected" via the translation function. So I have something like this:
vocabtest (no language test)
- term-de1 (de-language set, "connected" to term-en1)
- term-en1 (en-language set, "connected" to term-de1)
- term-de2 (de-language set, "connected" to term-en2)
- term-en2 (en-language set, "connected" to term-de1)
vocabtest is set as required vocabulary for page. So it should show the terms for the current langauge whenever I add a page. But it doesn't show any vocabulary at all. The reason is, that i18n add "where v.language = 'xy'" to the taxonomy query, so it only selects vocabularies where the language is set to the current language. As languages are not set on vocabularies, but on terms in the vocabulary, no vocabulary at all is shown.
..- Wonderland
Comment #3
davemybes commentedThis might be a problem with your installation, as I have used the last two versions of i18n, and both show the correct language terms. I tested this again with the Feb 3 version and it still works. To confirm my setup: vocab (no lang), eng-term (en), french-term (fr). Required or not doesn't change appearance/disappearance of terms. I do see another bug, though, in that the preview doesn't change terms when language is changed. I'll open a new issue for this as I don't think its related. I thought I'd just mention it though.
Comment #4
wonderland commentedI just tested again with the Feb 3rd release of i18n (and Drupal 5.1) and it still doesn't work for me. It might be something strange with my setup (although I re-installed several times while chasing this down) or I might just do something totally stupid that causes this. But from looking at the source code and analysing the database queries with the devel module, I fail to see how this could work. The taxonomy query is altered by the i18n module in such a way that is checks for the vocabulary language (where it imho should actually check the term language). When I apply the patch (as attached in my first post) it works fine.
Any chance you (or somebody else with a working i18n setup) could install and enable the devel module and set it to log and show all database queries? For adding a page node, the relevant query is listed as taxonomy_form_alter and looks like this with the latest i18n module installed:
SELECT v.* FROM vocabulary v INNER JOIN vocabulary_node_types n ON v.vid = n.vid WHERE (v.language ='en') AND ( n.type = 'page' ) ORDER BY v.weight, v.nameNotice that it checks "WHERE (v.langauge='en')", e.g. it checks the vocabulary language, not the term language (at least in my setup). When I apply my patch the same query looks like this:
SELECT v.* FROM vocabulary v INNER JOIN vocabulary_node_types n ON v.vid = n.vid LEFT JOIN term_data term ON v.vid = term.vid WHERE (term.language ='en') AND ( n.type = 'page' ) ORDER BY v.weight, v.nameWould be interesting to see how the query looks on your system, maybe that helps to find out what's going on.
..- Wonderland
Comment #5
davemybes commentedOn my system, with a fresh install of i18n, this is what I get for the taxonomy_form_alter line:
And, yes, the vocab shows up with the correct term in the list.
There two other calls further down the devel list that might be interesting for you:
and
Just out of interest, what settings do you have in the advanced settings for 'multilingual system'? On my system, I haven't changed it from the default, which is the first option: 'Only current language and no language'
Comment #6
wonderland commentedThat might be the issue. I have it set to "Only current language". As you've set it to show no language as well, the query correctly selects all your vocabularies, because they have no language assigned. Let's wait what Jose thinks about this issue.
Thanks for your help.
..- Wonderland
Comment #7
huayen commentedI have same problem as wonderland, even though I installed latest i18n. I am using PHP4, maybe the problem occurs for PHP4 but not for PHP5. (Custom pagers module ever had such kind of problem :)
wonderland, what's your final test result?
Comment #8
jose reyero commentedI've changed language rewriting so conditions are 'relaxed' for taxonomy and also menus when in 'strict' mode (Only current language)
So I think this should be fixed by now. Please, try and let me know
Comment #9
(not verified) commented