You are here

function _i18n_variable_exit in Internationalization 5

Same name and namespace in other branches
  1. 5.3 i18n.module \_i18n_variable_exit()
  2. 5.2 i18n.module \_i18n_variable_exit()
  3. 6 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 1134
Internationalization (i18n) module

Code

function _i18n_variable_exit() {
  global $i18n_conf;
  global $conf;
  if ($i18n_conf) {
    $lang = _i18n_get_lang();
    $refresh = FALSE;

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