View source
<?php
function locale_install() {
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')");
}
function locale_uninstall() {
db_query('DROP TABLE {locales_meta}');
db_query('DROP TABLE {locales_source}');
db_query('DROP TABLE {locales_target}');
}