Also using Internationalization 7.x-1.0-beta4

Fatal error: Call to undefined function _i18n_variable_init() in /home/userwwwl/public_html/cms/d7/sites/all/modules/translation_management/icl_content/icl_content.menus.inc on line 210

The _i18n_variable_init function doest exist, however theres a i18n_variable_initialize function

Comments

ruth_delattre’s picture

It is throwing this error when setting the multilingual options for a menu to either translate or fixed language.

scholli-d’s picture

I can confirm the bug:

When I click
Structure -> Menus -> edit menu (for main menu) -> list links
I get a white page with the text
Fatal error: Call to undefined function _i18n_variable_init() in /.../modules/translation_management/icl_content/icl_content.menus.inc on line 209

I use version 7.x-1.x-dev of i18n.

damiandab’s picture

I have the same problem :(

haloola’s picture

me too

tamsoftware’s picture

Status: Needs review » Active

same here.

Trying a little research in the modules folder, it appears this function doesn't exist. There is a i18n_variable_initialize() function however. This could be a rename. I'll try renaming the four calls and will report.

#grep -R i18n_variable_init *

i18n/i18n_variable/i18n_variable.module: i18n_variable_initialize();
i18n/i18n_variable/i18n_variable.module:function i18n_variable_initialize($language = NULL) {
translation_management/icl_content/icl_content.menus.inc: $i18n_v_orig = _i18n_variable_init($default->language);
translation_management/icl_content/icl_content.menus.inc: $i18n_v_target = _i18n_variable_init($lang->language);
translation_management/icl_content/icl_content.module: $i18n_v_orig = _i18n_variable_init($original->language);
translation_management/icl_content/icl_content.module: $i18n_v_target = _i18n_variable_init($code);


It works ! It seems The Variable Translation module must be activated though.

I now get two notices :

Notice : Trying to get property of non-object in i18n_variable_initialize() (line 53 in (...)/sites/all/modules/i18n/i18n_variable/i18n_variable.module).
Notice : Trying to get property of non-object in i18n_variable_initialize() (line 54 in (...)/sites/all/modules/i18n/i18n_variable/i18n_variable.module).

tamsoftware’s picture

Status: Active » Needs review

I'll try to make a patch file, but until I learn how to do that, this is what I did:

In your Drupal 7 installation, go to your sites/all/modules/translation_management folder
go to the icl_content folder inside

change _i18n_variable_init to i18n_variable_initialize in the following files:

icl_content.menus.inc at lines 209 and 219
icl_content.module at lines 2145 and 2146

Save and try. Make sure module MULTILINGUAL - INTERNATIONALIZATION: Variable Translation is activated.

Cheers

Franck Horlaville
TAM Software

tebb’s picture

Status: Active » Needs review

Getting the same error.

tebb’s picture

Thanks TAM Software,

I have applied the fix in #6 including enabling variable translation.

I can now list and edit menu entries, but I get the following notice when listing menu links:

Notice: Trying to get property of non-object in i18n_variable_initialize() (line 53 of /d7/sites/all/modules/i18n/i18n_variable/i18n_variable.module).

Looking at the variable translation configuration, I see that no variables are actually selected for translation. Should something be selected?

There is an entry in the variable translation list that says: Unknown variable unknown_variable We have no meta information for this variable. Please, ask module developers to declare their variables. See Variable module.

I guess this notice might be caused by another issue.

wvlgen’s picture

I have still the same problems after applying the patches in #6:

Fatal error: Call to undefined function _i18n_variable_initialize() in.../public_html/modules/translation_management/icl_content/icl_content.menus.inc on line 209

I have tried various combinations of the variables: all or some, but there is no difference.

tebb’s picture

@wvlglen

You don't need the first '_'

It's just: i18n_variable_initialize

wvlgen’s picture

Hello,

Thanks Dru-p: it works.

But I still get the following errors:

Notice: Trying to get property of non-object in i18n_variable_initialize() (line 53 of .../public_html/modules/i18n/i18n_variable/i18n_variable.module).
Notice: Trying to get property of non-object in i18n_variable_initialize() (line 54 of .../public_html/modules/i18n/i18n_variable/i18n_variable.module).

But at least I can continue to work.

tebb’s picture

@wvlglen

I get the same 2 notices - see #8.

I do not have a solution for that yet.

david_de’s picture

The solution in #8 seems to have solved all my menu problems. I was getting the errors on selecting menu edit in place of the edit page I had the error message.

haloola’s picture

same as #11

scholli-d’s picture

I now use version 7.x-1.0-beta5 of i18n and installed the variable module (version 7.x-1.0), with this configuration the error does not occur. Now there are two messages left:

Notice: Undefined index: i18n_mode in i18n_menu_translation_menu_access() (line 72 of /.../sites/all/modules/i18n/i18n_menu/i18n_menu.module).
Notice: Undefined index: i18n_mode in i18n_menu_translation_menu_access() (line 72 of /.../sites/all/modules/i18n/i18n_menu/i18n_menu.module).
tebb’s picture

I am using the same versions mentioned by Scholli in #15, but I still get the notices for lines 53 and 54 shown in #11.

scholli-d’s picture

#15 is not valid. I moved the i18n-module which did not work properly. Sorry for the wrong announcement!

kalmarr’s picture

I don't good idea:

I simple delete the code line

209 // $i18n_v_orig = i18n_variable_init($default->language);

If I make it I use the menu. I don't get error message.

I am waiting the fix it.

THX

KALMI

Stefan Haas’s picture

+1

astutonet’s picture

I also have the same erros. I'm also waiting a fix. Tks.

pedrojo’s picture

I had the same erros, but with the solution of #6 the problem of white-page when I like edit a menu didn´t have passed again. Certainly, the notices has gone, but for now has not affected the proper development of my site.

tamsoftware’s picture

As promised, here's the patch file for #6

Franck Horlaville
TAM Software

jwilson3’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #22 works. Hoping to see this in beta2 soon ;)

jwilson3’s picture

Status: Reviewed & tested by the community » Needs work

Upon closer investigation, i revoke my rtbc status... there are a few things wrong here:

1) At the very least, the patch needs to check to confirm the i18n_variable module exists before trying to use its functions. Eg:

function icl_content_menu_overview_form_alter(&$form, $form_state) {
  if (module_exists ( 'i18n' ) && module_exists('i18n_variable')) {  
  }
}

2) i18n_variable_initialize() function doesn't return anything and hence this logic will never be true:

$i18n_v_orig = i18n_variable_initialize($default->language);
foreach ($variables as $v_name) {
  if ($i18n_v_orig[$v_name] == $form['#menu']['menu_name']) {
    // the code here will never be executed
  }
}

The initialize function is called by the i18n_variable modules hook_init function... this isn't what we need. I think the function we're looking for instead is i18n_variable_load?

jwilson3’s picture

Status: Needs work » Needs review
StatusFileSize
new2.5 KB

Here's a patch for #24.

Replaces _i18n_variables_init() with i18n_variable_load(), and checks to ensure i18n_variable module is enabled first.

gmetrail’s picture

Patch for #24 solves the problem on my server.

stefgosselin’s picture

+1 for patch #25, it did the job nicely.

kurtzhong’s picture

Patch #25 rocks!!

jwilson3’s picture

rtbc anyone?

miro_dietiker’s picture

Status: Needs review » Closed (won't fix)

Currently we're reimplementing this module from scratch in our codesprint:
http://drupalevents.ch/drupal/codesprint-2012

Thus all current bug reports and feature requests are dropped. Please recheck once the the sprint is completed.

Thanos Lappas’s picture

#25 patch works fine

spyckedelic’s picture

I am having the same error, but I am fairly new to drupal and I am afraid to mess things up.
I haven't used patches before and it seems a quite complicated procedure.

Is there no easier way to fix this problem? :(

spyckedelic’s picture

When using patch from #25 I get this error:

can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|Index: icl_content/icl_content.module
|===================================================================
|--- icl_content/icl_content.module (revision 584)

spyckedelic’s picture

I fixed it!

I had to enter patch -p0 < (patch file) and then it worked!

Webmacahan’s picture

I´ve installed the patch and have verified the changes in the files, still getting the same error: "Fatal error: Call to undefined function _i18n_variable_initialize() in.../modules/translation_management/icl_content/icl_content.menus.inc on line 209".
I´ve uninstalled and re-installed all the relevant modules and have run the update script but nothing seems to help.
Any ideas?

ibarrajo’s picture

I've just encountered this error in Drupal 7.21 using Commerce Kickstart

It appears the devs in charge of internationalization have changed the name of the function in charge of initializing the variables from _i18n_variable_init() to i18n_variable_language_init()

Just go and change the lines to:
icl_content.menus.inc
209: $i18n_v_orig = i18n_variable_language_init($default->language);
219: $i18n_v_target = i18n_variable_language_init($lang->language);

and:
icl_content.module
2145: $i18n_v_orig = i18n_variable_language_init($original->language);
2146: $i18n_v_target = i18n_variable_language_init($code);

musa1234’s picture

Component: Code » Documentation
Assigned: Unassigned » musa1234
Category: bug » task
Priority: Major » Critical
Status: Closed (won't fix) » Closed (fixed)

hi guys i manage to fix the issue for you

please paste this function under sites/all/modules/i18n/i18n_variable/i18n_variable.module ,it seems to be missing

function i18n_variable_initialize($language = NULL) {
  $language = $language ? $language : i18n_variable_language();
  $GLOBALS['language_variable'] = $language;
  $variables = i18n_variable_load($language->language);
  variable_realm_add('language', $language->language, $variables, 10);
  variable_realm_switch('language', $language->language);
}
fadyfawzey’s picture

Here is my solution Drupal Users , it solves all the problems to me :

Go to under sites/all/modules/translation_management/icl_content/icl_content.menus.inc ,
Go to the error line and change i18n_v_orig = _i18n_variable_init($default->language); to be $i18n_v_orig = i18n_variable_language_init($default->language);

Then watch the magic work :) ...
Hope that maintainer update his module to implement that .

tonybaldwin’s picture

I did that. It didn't help.
Just changes the error to
Fatal error: Call to undefined function _i18n_variable_initialize() in ../sites/all/modules/translation_management/icl_content/icl_content.menus.inc on line 209

GLinBoy’s picture

thanks ibarrajo,
Your solutionwork for me ;-)
I use Internationalization 7.x-1.8 on Drupal 7.22; my site languages is English (default) & Persian;