You are here

function locale_install in Drupal 5

Same name and namespace in other branches
  1. 8 core/modules/locale/locale.install \locale_install()
  2. 6 modules/locale/locale.install \locale_install()
  3. 7 modules/locale/locale.install \locale_install()
  4. 9 core/modules/locale/locale.install \locale_install()

Implementation of hook_install().

File

modules/locale/locale.install, line 6

Code

function locale_install() {

  // locales_source.source and locales_target.target are not used as binary
  // fields; non-MySQL database servers need to ensure the field type is text
  // and that LIKE produces a case-sensitive comparison.
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {locales_meta} (\n        locale varchar(12) NOT NULL default '',\n        name varchar(64) NOT NULL default '',\n        enabled int NOT NULL default '0',\n        isdefault int NOT NULL default '0',\n        plurals int NOT NULL default '0',\n        formula varchar(128) NOT NULL default '',\n        PRIMARY KEY (locale)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {locales_source} (\n        lid int NOT NULL auto_increment,\n        location varchar(255) NOT NULL default '',\n        source blob NOT NULL,\n        PRIMARY KEY (lid),\n        KEY source (source(30))\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("CREATE TABLE {locales_target} (\n        lid int NOT NULL default '0',\n        translation blob NOT NULL,\n        locale varchar(12) NOT NULL default '',\n        plid int NOT NULL default '0',\n        plural int NOT NULL default '0',\n        KEY lid (lid),\n        KEY lang (locale),\n        KEY plid (plid),\n        KEY plural (plural)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {locales_meta} (\n        locale varchar(12) NOT NULL default '',\n        name varchar(64) NOT NULL default '',\n        enabled int NOT NULL default '0',\n        isdefault int NOT NULL default '0',\n        plurals int NOT NULL default '0',\n        formula varchar(128) NOT NULL default '',\n        PRIMARY KEY (locale)\n      )");
      db_query("CREATE TABLE {locales_source} (\n        lid serial,\n        location varchar(255) NOT NULL default '',\n        source text NOT NULL,\n        PRIMARY KEY (lid)\n      )");
      db_query("CREATE TABLE {locales_target} (\n        lid int NOT NULL default '0',\n        translation text NOT NULL,\n        locale varchar(12) NOT NULL default '',\n        plid int NOT NULL default '0',\n        plural int NOT NULL default '0'\n      )");
      db_query("CREATE INDEX {locales_target}_lid_idx ON {locales_target} (lid)");
      db_query("CREATE INDEX {locales_target}_locale_idx ON {locales_target} (locale)");
      db_query("CREATE INDEX {locales_target}_plid_idx ON {locales_target} (plid)");
      db_query("CREATE INDEX {locales_target}_plural_idx ON {locales_target} (plural)");
      db_query("CREATE INDEX {locales_source}_source_idx ON {locales_source} (source)");
      break;
  }
  db_query("INSERT INTO {locales_meta} (locale, name, enabled, isdefault) VALUES ('en', 'English', '1', '1')");
}