Language setting not taken into account when adding new menu items. It's on "English" in the form but after submitting the new items it's on "All languages" for all added items.

Comments

okokokok’s picture

Found out that the language is stored correctly if I first change it from English to another language.

donquixote’s picture

A note to the clueless:
This bug only applies if you have the "Menu Translation" module (i18nmenu) enabled.
(submodule shipped with i18n)

donquixote’s picture

The fix is quite simple:
I just need to set the default value for language to an empty string.

However, there is some other stuff I need to take into account for the i18nmenu.
Basically, I have to copy the mechanics from the menu_edit_item form.
This form is modified by i18nmenu_form_menu_edit_item_alter(), and gets additional validation and submit callbacks:

<?php
  array_unshift($form['#validate'], 'i18nmenu_menu_item_prepare_normal_path');
  $form['#submit'][] = 'i18nmenu_menu_item_update';
?>

The i18nmenu_menu_item_update() calls _i18nmenu_update_item(), which calls _i18nmenu_get_item(), which calls tt(), which calls i18nstrings_update_string(), which calls i18nstrings_add_string(), which writes to db tables {locales_source}, {locales_target}, {i18n_strings}. Just so you get an idea..

For the submit mechanics it will probably be enough to call _i18nmenu_update_item() for every new or modified item, after it has been saved.

For validation, I should first add some very basic checks, then I can add i18nmenu_menu_item_prepare_normal_path().

donquixote’s picture

A new version is on CVS, including:
- the bug fix for language settings
- the bug fix for order of items
- a bunch of new features
- probably some new bugs.

I hope the packaging script will run soon.

donquixote’s picture

Packaging script has run, and the fixed code can be downloaded with the latest 6.x-1.x snapshot.

donquixote’s picture

Status: Active » Needs review

There is no status "committed to snapshot release", so I set this to "needs review".
Others would set it to "fixed", but I don't like this. It's fixed when it's officially released!

donquixote’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.