You are here

function _i18n_variable_init in Internationalization 5.3

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

Load language variables into array

1 call to _i18n_variable_init()
i18n_variable_init in ./i18n.module
Initialization of multilingual variables

File

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

Code

function _i18n_variable_init($language, $prefix = '') {
  $variables = array();
  $cacheid = 'variables:' . $language . ($prefix ? ':' . $prefix : '');
  if ($cached = cache_get($cacheid)) {
    $variables = unserialize($cached->data);
  }
  else {
    $result = db_query("SELECT * FROM {i18n_variable} WHERE language='%s' AND name LIKE '%s%'", $language, $prefix);
    while ($variable = db_fetch_object($result)) {
      $variables[$variable->name] = unserialize($variable->value);
    }
    cache_set($cacheid, 'cache', serialize($variables));
  }
  return $variables;
}