I got a strange issue, few weeks ago, multilingual variables was working but now, all multilingual variable are save in table 'i18n_variable' and also in 'variable'.
And when varaible_get() function get it, it's take this from the table 'variable'.
I don't know maybe it starts after i've install l10n_client module. If some already had this issue, he's welcome.
Thanks

CommentFileSizeAuthor
#24 i18n_variables_ls.patch1.45 KBanschinsan

Comments

raphael apard’s picture

I try to disable all other module, but multilingual variables still not working.

raphael apard’s picture

It's working with i18n.module 1.4 but not with 1.5

raphael apard’s picture

Component: User interface » Code
Status: Active » Needs review

Problem comes from this function :

function _i18n_init($check_frontpage = FALSE) {
  static $i18n_done;

  // Prevent this function from running twice;
  if (!isset($i18n_done)) {
    $i18n_done = TRUE;
    $default_frontpage = variable_get('site_frontpage', 'node');

    i18n_variable_init();

    // We do aditional frontpage check if this has run after first bootstrap phase.
    // But if this runs in hook_boot we should be ok
    if ($check_frontpage && $default_frontpage != variable_get('site_frontpage', 'node') && $_GET['q'] == drupal_get_normal_path($default_frontpage)) {
      $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
    }
  }
}

This function is called a first time by function i18n_boot() and a second time by function i18n_init().
This second time, i18n_variable_init() is not called because of static variable $done.
But for multilingual variable works, i18n_variable_init() has to be called by i18n_init() (only tested in in my case).

So i had to called i18n_variable_init() outside of if (!isset($i18n_done)) in function i18n_init().

ayalon’s picture

Title: multilingual variable does not anymore » Multilingual Variables aren't working anymore
Priority: Normal » Critical

This is highly critical! All multilingual variables aren't working in 1.5.

I had the same problem with the "Add to cart" button and ended up in this thread.

This should be immediately fixed.

But probably this is not the best way to fix this.

For me, this solution worked:

function _i18n_init($check_frontpage = FALSE) {
  static $done;
  i18n_variable_init();
  
  // Prevent this function from running twice;
  if (!isset($done)) {
    $done = TRUE;
    $default_frontpage = variable_get('site_frontpage', 'node');

    //i18n_variable_init();

    // We do aditional frontpage check if this has run after first bootstrap phase.
    // But if this runs in hook_boot we should be ok
    if ($check_frontpage && $default_frontpage != variable_get('site_frontpage', 'node') && $_GET['q'] == drupal_get_normal_path($default_frontpage)) {
      $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
    }
  }
}

skylord’s picture

Subscribing.
BTW, fix above doesn't work for frontpage variable - it's skill default one and not language specific.
As a temporary workaround i've completely remove surrounding "if"-statement with !isset($done) check. It works fine now.

Anonymous’s picture

Subscribing.

xibun’s picture

+1

ezar’s picture

+1

ezar’s picture

Status: Needs review » Active

In Ubercart module are defined these variables in hook_init

global $conf;
$conf['i18n_variables'][] = 'uc_store_name';
$conf['i18n_variables'][] = 'uc_field_first_name';
$conf['i18n_variables'][] = 'uc_field_last_name';
$conf['i18n_variables'][] = 'uc_field_email';
$conf['i18n_variables'][] = 'uc_field_phone';
$conf['i18n_variables'][] = 'uc_field_company';
$conf['i18n_variables'][] = 'uc_field_address';
$conf['i18n_variables'][] = 'uc_field_street';
$conf['i18n_variables'][] = 'uc_field_street1';
$conf['i18n_variables'][] = 'uc_field_street2';
$conf['i18n_variables'][] = 'uc_field_city';
$conf['i18n_variables'][] = 'uc_field_zone';
$conf['i18n_variables'][] = 'uc_field_postal_code';
$conf['i18n_variables'][] = 'uc_field_country';

but variable_get('uc_store_name') doesnt return correct translation.

I change i18n_variable_init(); to call out "isset($done)" and works, but is it a correct solution?

eZar.

jax’s picture

Defining i18n_variables in hook_init() doesn't (always) work. You should copy/paste those declarations to your settings.php. In the user interface they will be marked as multilingual variable but when loading the value will be ignored.

mafioso’s picture

+1 *waiting for a working patch*

jose reyero’s picture

Status: Active » Fixed

This should work now. We don't check anymore $i18n_variables when doing variable loading (which was before all modules were loaded).

So all these variables should be translated as long as they're there when doing settings form alters.

ezar’s picture

Status: Fixed » Needs work

Does not work.
When I use this patch all variables saved to cache. If I'm using mobile_tools to change theme it store theme_default to cache.

jose reyero’s picture

Status: Needs work » Postponed (maintainer needs more info)

@ezar,

It should work with latest version (1.7) unless your theme_default variable is also multilingual, which won't be compatible with mobile_tools.

anea02’s picture

I can confirm that this is now working using version 1.7. I was experiencing the exact same issue (Ayalon) but with 1.6, upgraded to 1.7 and the problem went away.

Gracias Jose. :-)

Solucionaste el problema muy rapido!

Adam

stroobl’s picture

In the case of ubercart fields (see #9), it seems to work with 1.6 but 1.7 is broken again for me. Any idea why? (I declared the i18n variables in settings.php)
I've been comparing the code changes between 1.6 and 1.7, but I'm not really an i18n specialist and there are many changes. ;-(
There is also an issue for this in the ubercart queue: http://drupal.org/node/834290

Al01’s picture

Version: 6.x-1.5 » 6.x-1.7
Status: Postponed (maintainer needs more info) » Active

I can confirm that the display issue found in #3 & #4 is working again.

But this is not the whole story. UC saves sometimes variables in hook_form_submit() which seems not to be supported by i18n anymore. See details at http://drupal.org/node/834290#comment-3786882

@Jose: This is a major change in functionality and there are more modules affected. Do they all have to change the way how to build there forms or can we get hook_form_submit() - support back?

TIA

kslagboom’s picture

Subscribing

Dokuro’s picture

subscribing

wpanssi’s picture

I'm using menu trails module. I'm trying to turn the form items in admin/build/menu/trails into multilingual variables. I added

$conf['i18n_variables'] = array(
  'menutrails_node_types[page]',
  'site_name');

in the settings.php. The multilingual settings work for site_name but not for menutrails_node_types[uutinen], not even with 6.x-1.7.

Any clue how to fix this?

Dokuro’s picture

Does this work with 1.6?

wpanssi’s picture

I have tested it now with 1.4, 1.5, 1.6 & 1.7. Doesn't seem to work..

tky’s picture

Subscribed.
In my site, only siten_ame and frontpage fields worked...
Waiting for the solution.

anschinsan’s picture

Version: 6.x-1.7 » 6.x-1.9
Status: Active » Needs review
StatusFileSize
new1.45 KB

Hi guys,

I think I've found the problem and solved it. I tested a lot - but before setting it productive, it would be nice if you could confirm, that my patch works. (Attention: original i18n.module version was the latest recommended 6.x-1.9)

Thanks for your feedback!
anschinsan

jose reyero’s picture

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

No follow up for too long. Cleaning up issue tracker for 6.x. Consider upgrading to 7.x

(Sorry, it seems no one else is willing to test your patch)