You are here

function locale_update_6000 in Drupal 6

{locales_meta} table became {languages}.

Related topics

File

modules/locale/locale.install, line 25

Code

function locale_update_6000() {
  $ret = array();
  $schema['languages'] = array(
    'fields' => array(
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'native' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'direction' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'enabled' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'plurals' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'formula' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'domain' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'prefix' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'javascript' => array(
        //Adds a column to store the filename of the JavaScript translation file.
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'language',
    ),
    'indexes' => array(
      'list' => array(
        'weight',
        'name',
      ),
    ),
  );
  db_create_table($ret, 'languages', $schema['languages']);

  // Save the languages
  $ret[] = update_sql("INSERT INTO {languages} (language, name, native, direction, enabled, plurals, formula, domain, prefix, weight) SELECT locale, name, name, 0, enabled, plurals, formula, '', locale, 0 FROM {locales_meta}");

  // Save the language count in the variable table
  $count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1'));
  variable_set('language_count', $count);

  // Save the default language in the variable table
  $default = db_fetch_object(db_query('SELECT * FROM {locales_meta} WHERE isdefault = 1'));
  variable_set('language_default', (object) array(
    'language' => $default->locale,
    'name' => $default->name,
    'native' => '',
    'direction' => 0,
    'enabled' => 1,
    'plurals' => $default->plurals,
    'formula' => $default->formula,
    'domain' => '',
    'prefix' => $default->locale,
    'weight' => 0,
  ));
  $ret[] = update_sql("DROP TABLE {locales_meta}");
  return $ret;
}