Integrate with I18n (I) - "Localize terms"
oliverhuynh - October 3, 2008 - 11:47
| Project: | Taxonomy Menu |
| Version: | 6.x-2.x-dev |
| Component: | User interface |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Dear !
I've found Taxonomy_Menu is not integrated with I18n, a multilanguage module. I've fixed some code in Taxonomy_Menu for the module to integrate with I18n. Please review.
I18n is here: http://drupal.org/project/i18n
Regards,
Oliver Huynh
| Attachment | Size |
|---|---|
| taxonomy_menu.module.patch | 966 bytes |
| taxonomy_menu.inc_.patch | 1.71 KB |

#1
thanks, seem to work fine for me!
#2
Just noticed - 'expanded' options doesn't apply for other languages so we either need to display all items translations in menu settings (like it works for taxonomy i18n) or apply 'expanded' option to translated terms automatically (I believe it can break things if translated taxonomy structure differs from original one).
Any chance to look at it?
#3
Hi,
I have this problem: installed taxonomy menu, configured, but when I change language by Language Switch block, taxonomy menu doesn't update.
To achieve this behaviour I HAVE to "Clear cache" from devel block.
For example, I have this:
Vocabulary
- Term 1 (english)
-- Term 1-1 (english)
- Term 1 (italian)
-- Term 1-1 (italian)
-- Term 1-2 (italian)
Correspondent terms are translated between languages. When I select Italian from language switcher, taxonomy menu still shows english terms (or vice versa).
I HAVE to clear cache to make taxonomy menu to reflect language switching, and so to make ONLY language specific terms to be visible.
Do I miss something?
Thanks for any help.
#4
Patch seems to be working just fine.
#5
sylvaingirard wrote:
I wrote:
Yes: my mistake when applying the patch.
Thanks, sylvaingirard.
#6
Can you please write a patch that applies to the newest DEV? It is a total rewrite and the current patch no longer applies.
#7
Success! works for me too. Can these patches find their way into the current version please. Thanks for your work developing and tuning this module.
#8
same problem as Sisma_Net - January 21, 2009 - 19:21
#9
Is there a version available that contains this patch, because I have no experience in patching modules.
How do I apply a patch? Do I need a special program for this?
#10
This patch was written against the previous version. Taxonomy Menu has been totally reprogrammed and the patch no longer applies. I need it ported to the latest version and I will be part of the release.
#11
This is the 6.x.1.02 release patched with the codes published by oliverhuynh - October 3, 2008 - 12:47 for people interested in.
I didn't find the sources for an automatic patch to work then I patched manually as I do most of the time, finding the -lines and replacing by the +lines.
Seems to work at the moment.
Edit: I have to do a refresh in "Translate Interface" sometimes. Else some terms, not all, change language.
#12
When will this patch be ported and included in 6.x-2.x?
Now I have created 3 menus (one for each languages), but switching between languages does not work.
The only solution is one menu with terms translated into three languages. So I need this patch in 2.x. Thanks!
#13
I added t() are the menu link title (sorry that I missed that in the first version) I'm not sure if this will resolve this issue. Please test and let me know. Look for the DEV version after today.
#14
i just downloaded the today 2.x-dev commit #184322 and tested on my test site.
I have localized terms.
That changed nothing for me. All terms keep untranslated.
I like this improved module.
#15
I have also installed the latest 6.x-2.x-dev of March 17.
I have 3 languages: English, French and Dutch.
I use per language terms as translation mode for my vocabulary.
Every term is translated in French and Dutch.
The menu shows all terms in all languages.
Normally, only terms that correspond to the chosen language should appear.
Nothing changed, the problem remains.
#16
Thanks for the testing. I"ll dig a little deeper.
#17
Ok. Attempt number 2. The main issue is that taxonomy menu doesn't handle the displaying of the menu, only saving the menu links. I'm not sure if I should be changing the taxonomy part of the code or the menu part of the code. In this version I changed the code that pulls the term id for the current language. I'm not sure if this will work. It's more to rule it out.
I do apologize as this is my first time coding with i18n.
#18
This version (of March 18) does not work. The menu is totally messed up and is not useable.
So you can rule it out, I think.
#19
Thanks. I'll roll back that change and go into a different direction. I appreciate the patience.
#20
Ok. Attempt number...
This time I looked through the i18nmenu code and saw that it alters the menu links as they are being saved. So I'm looking up the language for the term and placing it on the $link array as it's being passed to menu_link_save.
Please give this version a try. The DEV should be release in a few hours (overnight for me).
#21
Hi, I have tested the new DEV of March 19.
The problem remains: all terms are shown for every language. I use English (default), Dutch and French.
When I go to Site Building >> Menu I noticed following things when I edit the terms:
1. Terms (in English = default language) that are not yet translated in the taxonomy are set to: "All languages".
2. For already translated terms: English terms are set to Dutch, Dutch ones to French and French ones to Dutch.
When I set the language manually in this edit dialogue and save it, the menu items are correctly displayed according to the selected language.
I hope this information helps...
#22
Thanks for testing. I'll keep digging. I thought I had it there.
#23
I use i18n menu differently from tomsm.
To be more precise I use "Localize terms. Terms are common for all languages, but their name and description may be localized.". Default language "English" for locale.
Nothing translated.
Thank you for your work.
#24
subscribing. (I also use i18n with "Localize terms. Terms are common for all languages...").
#25
I'm posted in http://drupal.org/node/405742 and setting status "duplicate" :(
in new version i have same problem, see attach
vocab "Город" & "Мероприятия" should not show (curent language = esperanto)
#26
There is still no resolution to this issue yet. The newest version does not have a fix.
#27
Tested DEV of March 23.
I use "Localize terms. Terms are common for all languages, but their name and description may be localized.". Default language "English" for locale.
I have good links for taxonomy terms, but terms name remain untranslated
http://www.example.com/en/taxonomy/term/46 (term name: Apple - Default language)
http://www.example.com/es/taxonomy/term/46 (term name unchanged: Apple instead of Manzana)
http://www.example.com/fr/taxonomy/term/46 (term name unchanged: Apple instead of Pomme)
#28
I need some help with this. Form what I can see it should work. I would be very grateful if someone would submit a patch.
#29
I have tested version 6.x-2.2 and the menu is totally messed up. Also the latest DEV of March 25 appears to have the same effect.
Many terms are children of various other terms etc. Really strange behaviour.
After reinstalling the DEV of March 23 the menu is useable again. All terms are set to "All languages" in the menu settings. When I edit a term in taxonomy it is reset to "All languages". I hope someone finds a patch fixing this i18nmenu setting. Thanks!
#30
Ok. I compared the two versions and made the dev the same. Now it's back to square one to figure out how to get the correct menu items to display.
I do apologize for the issues, i18n is very new to me.
Neil
#31
Similar to others I use taxonomy with "Localize terms. Terms are common for all languages, but their name and description may be localized." It is very convenient to maintain the translations with the "Translation table" module if you do it like that.
You will notice that the "Translation table" module has two separate translation tables for taxonomies and menus. In fact, these translations are kept apart with the "textgroup" field in the table "locales_source". If that field is set to "taxonomy", then it's a translation for a taxonomy term, if it is set to "menu", then it's a translation for a menu item.
When Drupal displays the menu, it looks up the translation for the textgroup "menu", not for "taxonomy". That's why the translations do not work for taxonomy terms in menus.
So what "Taxonomy menu" actually should do, but fails to do so far, is duplicate the entries with textgroup "taxonomy" to corresponding entries with textgroup "menu" whenever it creates a menu (and remove these entries when the menu is removed).
#32
Thanks Cito. That's the piece I was missing.
#33
Here is a try of implementation for term localization and taxonomy_menu.
This patch use directly terms translations on the menu (translation from textgroup 'taxonomy'), it doesn't duplicate strings in textgroup 'menu'.
So translations string are not in double and you don't need to add and maintain menu translations.
It may have side effects for others vocabulary multilingual options and need to be tested.
#34
Awesome niQo! Thanks! I'll do some basic testing but others, please give me test with various situations and I'll be very happy to commit this.
#35
NiQo's patch from #33 works (nice one!!) but has a small problem if the option "Item for Vocabulary" is checked.
When this is selected the vocabulary name item appears empty (same for all languages including default). All pages also show this error:
Menu and taxonomy name mismatch : TheNameOfYourVocabulary!=
Hopefully this detail is easy to sort out (let me know if more information about the problem would be useful).
#36
Nothing to add more than jonowindsurf except "Item for Vocabulary"
Just to say it seems to work for me.
#37
The issue only seems to occur if i18nmenu and item for vocabulary is active.
#38
It works for me too! Gread job. Thanks.
There are two problems:
1) Display Number of Nodes
gives me
Menu and taxonomy name mismatch : English term (14)!=English termMenu and taxonomy name mismatch : english term 2 (8)!=english term 2
Menu and taxonomy name mismatch : English term 3 (9)!=English term 3
and etc...
I don't thts possible, to fix easily. I suggest to give note, next to select box, that this doest'n work with translation of taxonomy.
2) Item for Vocabulary
Menu and taxonomy name mismatch : Vocabulary english name!=Custom Path works fine.
thx again
#39
I've done some research and here is my theory. These messages are occurring because there is no translation match for strings.
Display number of nodes because the title is actually a mix of words and numbers. I don't know of a way to fix this.
Item for Vocabulary because it doesn't seem that i18n creates a translation for the vocabulary. I don't know if you can manually add translations strings but you might try that.
#40
Have been looking through the database tables and it does appear that translations for vocabulary names ARE there (I also seem to remember translating the strings). I am not very familiar with how translation works but there do also appear to be entries in the "i18n_strings" table and corresponding entries in the "locales_source" and "locales_target" tables.
More on the error messages I get, initially I only noticed the first but there is another one...
1. "Menu and taxonomy name mismatch : NameOfVocabulary!=" (this on all pages).
2. "warning: preg_match() expects parameter 2 to be string, array given in C:\wamp\www\drupal\includes\bootstrap.inc on line 771." (this in addition to the previous error but only on pages/nodes that are part of a (any) taxonomy).
In both cases I only get the message if "Item for vocabulary" is checked. No errors if unchecked.
#41
It Works!!
I did a slow, step by step install in English, Afrikaans, Zulu, Xhosa and Seshuto and it works with:
Taxonomy translation enabled
menu translation enabled
and translation_table.module, (very nice string translation interface for taxonomy and menus)
Doing the following will cause the: NameOfVocabulary!= mismatch
Changing the term of a node when you translate it. It would be better if the Taxonomy selector on translated nodes was grayed out.
Thanks, great great module.
P.S. The title of the Term, shown on the top of Taxonomy pages does not translate. Code in the page.tmp file is responsable for the printing of those titels.
<?php if (!empty($title)): ?><h1 class="title"><?php print $title; ?></h1><?php endif; ?>#42
I have set the translation setting of my vocabulary to "Localize terms".
Then I have translated the English terms with the translation table module.
The English menu items are sorted alphabetically.
When I change the language the terms are not sorted alphabetically. How can I fix this?
Thanks!
#43
I have noticed that when items have the same weight they are ordered alphabetically.
So I have tried to set the weight of all menu items to 0, but the translation does not work anymore.
Does taxonomy module need different weight settings in order to work properly?
Maybe, it would be nice if there was an option to disable weights in taxonomy menu so that items are always ordered alphabetically in every used language....
#44
I have found a workaround.
After setting all menu items to weight 0, I have translated all menu items with translation table and the menu works ok.
I have noticed that when I change the weight of a menu item it loses its translation link within the taxonomy.
#45
Should the patch listed in comment 33 be applied to the current DEV version? or to the current 6x2.3 version?
#46
It has already been applied to the DEV version.
#47
Ok, I changed to the latest DEV version. Nothings different. I still have no clue how to have a Taxonomy Menu in 2 languages!! The Vocab is set to Localized terms, I translate the individual terms in the i18n Interface Translation. That doesn't really do anything for the menu. The menu items that Taxonomy Menu generates in the menu don't show up in the Translation Search, i cant translate them, I'm stuck!!!
This is for a vocabulary that will categorize blog posts by year/month for a click-able archive menu, so I was hoping that only one term needs to be picked, so someone translating content doesn't have to REPICK an additional french equivalent term when creating the node in the other language. I.E one term for the post, synced to the fr version so when hit the lang switcher, and you get the translated Menu-item/taxonomy term.
What am I doing wrong, what was this DEV patch for exactly.
Jeremy
#48
The translation works fine for me. I have English as default language + French and Dutch.
I also use localized terms. I have translated the terms with translation table.
Are your menu item settings correct? Language must be set to "All languages".
#49
Hi Glowingtree,
I don't know if this will help you but I have found a "not so elegant" workaround to the problem. It helps me further while waiting on a solution on the "Menu and taxonomy name mismatch"-problem. I too needed a taxonomy menu, with translations of terms and this is how I got it working "for now":
and voila... a multilanguage taxonomy menu...
As I said before not as clean as I would have wanted to with uber parent and so but it get's the job done...
Btw, great work with this module guy's.
There is only one thing I think is missing besides a solution on this problem of mismatched names. It would be great if you were able to select a menu-item instead of a full menu. That way it's much easier to place the tax_menu as a submenu without losing menu consistency. Because I know you can easely put this in a seperate menu and only show it on sertain page's but then you loose you're active state of you're main menu... Same thing for the breadcrumb. Unless there's another workaround???
#50
Hatznie, I basically have a similar setup, a main term (2009) which has sub-terms (Jan, Feb, Mar).
The only difference is that I created the taxonomy menu with regular version, then switched to DEV version. Should I have re-built the menu again? Also will the translated terms show up as translated menu items in the Taxonomy Menu when i switch to the other language? BTW I also applied the DHTML menu capability to my Taxonomy menu as well, i hope that isn't interfering with anything.
I will re-create and see what happens..
#51
re-created menu, works fine now.. that was the problem, no re-creation of menu after updating to dev vesion with patch applied
#52
ok, all the translated terms and menu items seem to be there for both languages. At least for my initial test post I tagged with the category "May" (shows up as Mai on fr side) But there is still a problem.
I get this mis-match error if go back to edit the translation of the node.
BTW The only options i have selected are "Syncronise changes to this Vocabulary" and "Hide Empty Terms"
how do i avoid this?
#53
my current issue probably has something to do with comment 41
Also, I notice when creating a node the drop down list appears fine with my taxonomy-menu vocabulary.
However when I hit the langauge switcher, so that the interface is in French, and try to create a french node, the list is empty. But I can switch back to english, and just choose to create the post in French via the lang selection in the node-add form, the taxonomy term drop down filled again. So this is dictating the way content is added on a multi lang site.. ) :
I have other non taxonomy-menu linked free-tag terms I need to be able to tag the nodes with as well. May be tricky for me to get around mismatch issue as stated above.
#54
This is an update to patch #33 against 6.x-2.3, which includes fixes to
- mismatch problem, including 'Display Number of Nodes' & 'Item for Vocabulary'
- blank vocabulary title for 'Item for Vocabulary'
- dynamic adding the number of nodes if enabled, the (COUNT) part is not part of translation
#55
#56
subscribing
#57
Is this problem also relevant if "Per language terms" is the setting for the vocabulary? Read through this issue but I am not sure?
#58
dddave: I'm trying to use this module with "Per language terms" but not having much success. it seems to work fine with the patch in #54 to localized terms - but i can't get the menu to properly display the correct menu links for every language with per language terms.
Has anyone had any success with this...?
UPDATE: I just went over this entire thread (again..).
After some more testings, it does seem to work quite well with localized terms.
I'm thinking: The only way for this to work with "Per language terms" vocabularies is to have Taxonomy Menu save the language of the term while adding/updating the menu item, as i18menu enables when activated. When using "per language terms" we have the language set at the taxonomy level (if we've set one) - but taxonomy menu does not pass this info to the menu system, and as such no language is set when saved as menu item.
So... I found this in taxonomy_menu.module, line 480:
//FIXME: i18nmenu need to be cleaned up to allow translation from other menu moduleif (module_exists('i18nmenu')) {
$link['options']['alter'] = TRUE;
}
I'm afraid i'm not exactly sure what this means, but i do think this is what we're looking for. I was thinking that adding a language in the arrays which are passed around would be sufficient - but no i have doubts. This may be more of an issue with i18nmenu then with taxonomy_menu.
Thought anyone?
#59
Ok...
I've added the following test code in taxonomy_module.module, in the latest -DEV version, in line 480:
//FIXME: i18nmenu need to be cleaned up to allow translation from other menu moduleif (module_exists('i18nmenu')) {
$link['language'] = 'he';
$link['options']['alter'] = TRUE;
}
This successfully sets the language of the menu item after a rebuild to Hebrew.
The weird thing is - All menu items still show for all languages!
Even if i manually edit and save them - they still show.
If i use taxonomy_module without this change menu item are set with no language. If i then manually set the language of the items, they work as expected and only display when viewing the language which they are set to. This is strange.
#60
Hi asak,
glad someone capabable has interest in it as I am definetly not the guy to digg into code. If you come up with a patch I am enthusiastic to test it.
Of course I experience the same problems as you with "Terms per language".
#61
Not sure that "capable" is the correct word here... ;)
After some more testing i found that i was partly wrong.
When manually setting the language of menu items, after taxonomy_menu creates them with no language set, does not function correctly.
That's odd.
I'll keep messing with this- but would sure appreciate some help here ;)
#62
Lol - I should really be more careful during previewing.
As I said I have no clue about coding but I can test patches. So I can only hope that someone can give you a hand or some clarifying insight.
#63
Getting closer:
I found a thread about i18nmenu: #253498: i18nmenu doesn't work with module-defined menu items. , and this comment with a patch: http://drupal.org/node/253498#comment-829150
The patch seems to be for a version other then 6.x-1.0 of i18n, which i'm using, but i was able to make the changes as such (starting line 39 of i18nmenu.module) and messed around with it until - I think i got it working! ;)
I'm attaching 2 patches - one for i18nmenu.module (1.2.2.11) the other for taxonomy_menu.module (1.19.2.2.2.36).
This is FAR FROM PERFECT and needs more work - but it works for me.
I tried it using the "Rebuild menu on submit" and tried manually adding a term to the system - both cases update the menu correctly.
i18n gurus - please have a look at this... not sure it's the correct way but could be a good start.
#64
Subscribing
#65
I must add - the patches in #63 disable to usage of localized terms, and only works for "Per language terms". it should all go into a big if {} or something... but that beyond my current experience...
#66
Well, first of all: All that commented-out code ought to be removed. It's rather cumbersome to tell what code has been added, when it's buried beneath heaps of "disabled" code.
#67
Working patch for "Localize terms" is at #54.
@asak / #64
If you are working on "Per language terms", please provide a clean patch rather than patch on top of other patches, we can't see your code nor what you are trying to do.
#68
I hope it is ok that I opened #498786: Integrate with i18n (II) - Solution for "Per language terms".
I think one task per issue is enough. ;) It tends to get messy when multiple patches about different problems are discussed in one issue.
So @asak
Please post the improved patches at the new issue.
#69
Is there anyone testing patch #54?
Let's concentrate only on "Localise Terms" in this thread @dddave kindly opened another issue.
#70
OK I have done some testing myself.
I still have the "Menu and taxonomy name mismatch" problem. Even though it does not really affect the way the website is working, it still makes taxonomy menu unusuable in a multilingual environment.
The translations in the translate interface are all fine, however I can't make the taxonomy menu to use these. If I rebuil the menu after having name mismatch problem, the problem goes away, until I create a new content. Maybe creating language neutral items are causing the problem. will check that as well.
At some point I have been able to make the menu translate itself according to the language selected. However, when I started to have "name mismatch" problems and I tweaked a little the settings in taxonomy and taxonomy menu, I can't this to work again. I am going to uninstall taxonomy menu completely and reinstall to double check the issue.
#71
subscribing
#72
I'm adding the patch on #54 to the next beta release.
#73
change status
#74
#54 Added to 2.4-beta1.
#75
#316632-70: Integrate with I18n (I) - "Localize terms":
Same for me.
#76
Sorry folks was not in UK for some time. Here I am back again.
@indytechcook: I was already using the the patch in #54. And still have the same problems.
Is anybody working on this issue or taxonomy menu is still unsuable in multilingual environment? Will try to solve it myself at some point but I am more keen on the layout of the site than the functionality issues at the moment. so it might take upto a month for me to start coding for Drupal (which will be the first attempt for me unfortunately).
#77
"Menu and taxonomy name mismatch" problem appeared for me when I added images to terms using "Taxonomy Image" module.
PS: It's not related whether the new content is language neutral, english or any other language.
#78
subscribe
#79
I am using 2.4-beta1 and as described in #74 patch is included in that version
I got the "Menu and taxonomy name mismatch" Warnings after adding some translations
Cleaning cache, and rebuilding the taxonomy menu did not work
but,
disabling and reenabling the menu for the vocabulary and all the Warnings went away
I have added a new term in vocabulary and translations and everything works fine ...
EDIT: spoke too soon
a little while later one Warning reappeared, disabled and enabled vocabulary again
and ALL warnings reappeared ...
if it makes any difference the menus appear to be working correct i18n-wise
but the warnings are annoying ...
#80
Same problem
#81
Added Comment from #619898: Update to beta3: menu items are not translated anymore - multilingual settings: localize terms
I have a site with 3 languages: English (default), Dutch and French.
When I update from 6.x-2.4-beta1 to beta3 and rebuild the menu, my menu items are not translated anymore. Whatever interface language I select, they remain in English.
My taxonomy multilingual settings are "Localize terms. Terms are common for all languages, but their name and description may be localized."
When I rebuild the menu with 6.x-2.4-beta1 there is no problem.
Other module information:
Drupal core: 6.14
Internationalization 6.x-1.x-dev (2009-Oct-20)
#82
Subscribing. Seem to have run into this issue.
#83
Subscribing
#84
subscribing
#85
subscribing
#86
It seems we are back to square one with beta3.
The menu translation does not work anymore, and we get a lot of warnings as a premium.
This is very anoying, Taxonomy menu is not usable at all now.
#87
The only major change was adding batchapi to create the menu. I added an option to make the use of batchapi optional. Please the latest dev should be available within 12 hours. Please test when it is.