The support of i18n taxonomy localization is broken.
When checking the code i see that you're relying on old (possibly D6) namings.
function taxonomy_menu_translated_menu_link_alter(&$item, $map) {
if (module_exists('i18ntaxonomy')) {
// In case of localized terms, use term translation for menu title.
Note that as a starting point, i18ntaxonomy was renamed to i18n_taxonomy. And tt() has been renamed as announced in the 6.x release.
This needs rewrite and extensive testing. This feature seems to be missed completely in the D7 port?
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | taxonomy_menu.zip | 8.37 KB | summit |
| #7 | fix_i18n_integration_2.patch | 4.83 KB | berdir |
| #3 | fix_i18n.patch | 4.82 KB | berdir |
Comments
Comment #1
dstolMarked #1229836: not working with i18n as duplicate
Comment #2
futurist commentedSubscribing
Comment #3
berdirThe attached patch fixes this.
Note that I also fixed a related problem that caused menu links to be saved in the wrong language. Previously, it only checked the node language and fell back to the current language. Now, it first checks if there is a term language. Without this, all menu links had the current language assigned instead of the actual term language (which is 'und' when it will be localized).
Comment #4
miro_dietikerThere's at leas one strange indentation.
For the TODO i don't know what would be needed. At least it seems to me the $display_num currently doesn't work anymore.
I think here $display_num should not be considered... The static item should be always without numbers. Am i wrong?
Please check with childterms.
Comment #5
berdir$display_num depends on helper functions that don't exist anymore. It doesn't work without i18n either I think.
That's probably why the check is currently wrong, yes.
Comment #6
miro_dietikerWhich helper is no more available?
I still see _taxonomy_menu_children_has_nodes() and taxonomy_term_count_nodes() is also there...
However, strange thing is to see this inside a i18n_taxonomy check. This number adding should be clearly outside i18n related alter topics...
Comment #7
berdirImproved the comment to state why the block is commented out.
That part is being worked on in #1165386: Node Count for D7 Version (patch included)
Comment #9
miro_dietikerLooks fine to me then.
Comment #10
dstolI'll get this into 7.x tonight once I'm home. It would be great if there were some tests included with this, as I don't really know much about i18n. Oh and thanks Berdir, I really appreciate your help!
Comment #11
miro_dietikergreat to see this proceed.
dstol, note that we're using it already in production this way.
Comment #12
dstolhttp://drupalcode.org/project/taxonomy_menu.git/commit/b07bfc7">Committed to 7.x-1.x-dev. Thank you!
Comment #13
healycn commentedsubscribe
Comment #15
summit commentedHi, Sorry to have to report that I think that in 7.1-dev the i18n support is still broken, see:
If I am mistaken on my part, much apologize, but I use the latest .dev version with this patch added: http://drupal.org/files/new-options-1192084-5.patch.
Greetings,
Martijn
Comment #16
summit commentedHi set this to active again.
This code doesn;t work anymore in D7:
See also http://drupal.org/node/603868
greetings,
Martijn
Comment #17
vvs commented#12 - it's working! Thanks!
Comment #18
summit commentedHi @VVS, How can it work with you when
is no function in D7 anymore?
greetings, Martijn
Comment #19
planctus commentedIt is working for me too with the dev version.
Thanks,
D.a
Comment #20
summit commentedHi,
I changed
for the function taxonomy_term_count_nodes to taxonomy_menu_term_count_nodes:
But still the errors from http://drupal.org/node/1228294#comment-5259532
Greetings, Martijn
Comment #21
summit commentedAttached is my taxonomy_menu module with patches: http://drupal.org/files/new-options-1192084-5.patch, and http://drupal.org/files/issues/fix_i18n_integration_2.patch and the changed function from http://drupal.org/node/1228294#comment-5464936
I also updated i18n to latest version.
But still taxonomy_menu_translated_menu_link_alter errors:
The error is somewhere in:
It has to do something with an empty value or an array I think, see: http://stackoverflow.com/questions/4798047/array-flipcan-only-flip-strin...
The function call itself looks ok, see: http://drupal.org/node/1123200#comment-4356314
May be needing an condition before it?
Thanks for going into this again!
Greetings, Martijn
Comment #22
dgastudio commentedthe problem is still present. any solution?
Comment #23
pieterdcAs @Summit states, the error is somewhere in that line of code.
If I replace
if (i18n_taxonomy_vocabulary_mode($t->vid, I18N_MODE_LOCALIZE)) {withif ($t !== FALSE && i18n_taxonomy_vocabulary_mode($t->vid, I18N_MODE_LOCALIZE)) {the error doesn't show any more.But I guess the real cause lies a little deeper:
In my case, the error was related to a taxonomy term with multiple parents... or maybe I just have some legacy data hanging around?
Comment #24
rondev commentedI would test $t before as it may be 0 for stray/invalid items as I explained here #1483010: [i18n] Localized stray item generate "array_flip() [function.array-flip]..." and "Trying to get property of non-object" errors. Else i18n_taxonomy_vocabulary_mode generate errors.
Comment #25
vvs commented#18 - i18n support working.
Comment #26
planctus commentedI'm pretty confused about this, i guess i've patched taxonomy_menu in the past in order to make it work with localized terms, it was working indeed.
Now i had a problem with a menu where i was missing items languages so i ran into this issue again.
I've read the last comment saying it was working, downloaded the latest dev and gave it a try..
It is not working for me, the menu items are all "language undefined", and that is pretty blocking since it is a very large vocabulary so it would be very hard to do that manually...
I must say i dont' have errors on screen while generating the menu items, by the way.
Thanks,
Da.
Comment #27
planctus commentedNobody answered, but the problem was there and it was quite trivial...
I'm not going to provide a patch, since the changes are really straightforward.
There is a typo at line 596 of taxonomy_menu.module, first:
if (module_exists('i18nmenu')) {The module is called i18n_menu, instead.
Second, at line 788, function _taxonomy_menu_create_item($args = array(), $node) {
'language' => $node ? $node->language : $GLOBALS['language']->language,It is unclear to me why $node has been used here...we have the taxonomy term object inside the $args parameter, it has already been set as $term, so we have to use $term->language instead of $node->language.
I made this changes and everything is working now.
Thanks,
Da.
Comment #28
dstol@planctus, could you please provide a patch? The line numbers you give don't match up with the latest code in 7.x-1.x-dev or did you patch against 7.x-1.2?
Comment #29
planctus commentedOk, i was working on the latest dev, i guess...so, i don't know why they don't match...
Da.
Comment #30
planctus commentedWell, i don't know exactly what version i was using, at this point, since both versions 7.x.1.x and 7.x.2.x already have the correct code.
So, no need for a patch, it is already fixed. But since this issue didn't ride on the problem i had i'm not closing it..
Thanks,
Da.
Comment #31
dstolClosing per planctus