You are here

function _i18n_variable_exit in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18n.module \_i18n_variable_exit()
  2. 5 i18n.module \_i18n_variable_exit()
  3. 5.2 i18n.module \_i18n_variable_exit()

Save multilingual variables that may have been changed by other methods than settings pages.

1 call to _i18n_variable_exit()
i18n_exit in ./i18n.module
Implementation of hook_exit().

File

./i18n.module, line 782
Internationalization (i18n) module.

Code

function _i18n_variable_exit() {
  global $conf, $i18n_conf;
  $langcode = i18n_get_lang();
  if (isset($i18n_conf[$langcode])) {
    $refresh = FALSE;

    // Rewritten because array_diff_assoc may fail with array variables.
    foreach (i18n_variable() as $name) {
      if (isset($conf[$name]) && isset($i18n_conf[$langcode][$name]) && $conf[$name] != $i18n_conf[$langcode][$name]) {
        $refresh = TRUE;
        $i18n_conf[$langcode][$name] = $conf[$name];
        db_query("DELETE FROM {i18n_variable} WHERE name='%s' AND language='%s'", $name, $langcode);
        db_query("INSERT INTO {i18n_variable} (language, name, value) VALUES('%s', '%s', '%s')", $langcode, $name, serialize($conf[$name]));
      }
    }
    if ($refresh) {
      cache_set('variables:' . $langcode, $i18n_conf[$langcode]);
    }
  }
}