You are here

function i18n_variable_set in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_variable_set()
  2. 5 i18n.module \i18n_variable_set()
  3. 5.2 i18n.module \i18n_variable_set()
  4. 7 i18n_variable/i18n_variable.module \i18n_variable_set()

Set a persistent language dependent variable.

Parameters

$name: The name of the variable to set.

$value: The value to set. This can be any PHP data type; these functions take care of serialization as necessary.

$langcode: Language code.

Related topics

2 calls to i18n_variable_set()
i18n_API_Tests::testBasicAPI in tests/i18n_api.test
i18n_variable_form_submit in ./i18n.module
Save multilingual variables and remove them from form.

File

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

Code

function i18n_variable_set($name, $value, $langcode) {
  global $conf, $i18n_conf;
  $serialized_value = serialize($value);
  db_query("UPDATE {i18n_variable} SET value = '%s' WHERE name = '%s' AND language = '%s'", $serialized_value, $name, $langcode);
  if (!db_affected_rows()) {
    @db_query("INSERT INTO {i18n_variable} (name, language, value) VALUES ('%s', '%s', '%s')", $name, $langcode, $serialized_value);
  }
  cache_clear_all('variables:' . $langcode, 'cache');
  $i18n_conf[$langcode][$name] = $value;
  if ($langcode == i18n_get_lang()) {
    $conf[$name] = $value;
  }
}