summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
Diffstat (limited to 'database')
-rw-r--r--database/database.mysql50
-rw-r--r--database/database.pgsql51
-rw-r--r--database/updates.inc85
3 files changed, 159 insertions, 27 deletions
diff --git a/database/database.mysql b/database/database.mysql
index 2e91654f2..75f1b51c5 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -255,25 +255,47 @@ CREATE TABLE history (
) TYPE=MyISAM;
--
--- Table structure for table 'locales'
+-- Table structure for table 'locales_meta'
--
-CREATE TABLE locales (
- lid int(10) NOT NULL auto_increment,
+CREATE TABLE locales_meta (
+ locale varchar(12) NOT NULL default '',
+ name varchar(64) NOT NULL default '',
+ enabled int(2) NOT NULL default '0',
+ isdefault int(2) NOT NULL default '0',
+ plurals int(1) NOT NULL default '0',
+ formula varchar(128) NOT NULL default '',
+ PRIMARY KEY (locale)
+) TYPE=MyISAM;
+
+--
+-- Table structure for table 'locales_source'
+--
+
+CREATE TABLE locales_source (
+ lid int(11) NOT NULL auto_increment,
location varchar(128) NOT NULL default '',
- string blob NOT NULL,
- da blob NOT NULL,
- fi blob NOT NULL,
- fr blob NOT NULL,
- en blob NOT NULL,
- es blob NOT NULL,
- nl blob NOT NULL,
- no blob NOT NULL,
- sw blob NOT NULL,
+ source blob NOT NULL,
PRIMARY KEY (lid)
) TYPE=MyISAM;
--
+-- Table structure for table 'locales_target'
+--
+
+CREATE TABLE locales_target (
+ lid int(11) NOT NULL default '0',
+ translation blob NOT NULL,
+ locale varchar(12) NOT NULL default '',
+ plid int(11) NOT NULL default '0',
+ plural int(1) NOT NULL default '0',
+ KEY lid (lid),
+ KEY lang (locale),
+ KEY plid (plid),
+ KEY plural (plural)
+) TYPE=MyISAM;
+
+--
-- Table structure for table 'menu'
--
@@ -620,7 +642,7 @@ CREATE TABLE users (
changed int(11) NOT NULL default '0',
status tinyint(4) NOT NULL default '0',
timezone varchar(8) default NULL,
- language char(2) NOT NULL default '',
+ language varchar(12) NOT NULL default '',
picture varchar(255) NOT NULL DEFAULT '',
init varchar(64) default '',
data longtext,
@@ -723,3 +745,5 @@ INSERT INTO filters VALUES (1,'filter',3,1);
INSERT INTO filters VALUES (2,'filter',1,0);
INSERT INTO filters VALUES (3,'filter',3,0);
INSERT INTO variable (name,value) VALUES ('filter_html_1','i:1;');
+
+INSERT INTO locales_meta (locale, name, enabled, isdefault) VALUES ('en', 'English', '1', '1');
diff --git a/database/database.pgsql b/database/database.pgsql
index 669889f7f..8092f0d87 100644
--- a/database/database.pgsql
+++ b/database/database.pgsql
@@ -242,25 +242,49 @@ CREATE TABLE history (
);
--
--- Table structure for locales
+-- Table structure for locales_meta
--
-CREATE TABLE locales (
- lid SERIAL,
+CREATE TABLE locales_meta (
+ locale varchar(12) NOT NULL default '',
+ name varchar(64) NOT NULL default '',
+ enabled int4 NOT NULL default '0',
+ isdefault int4 NOT NULL default '0',
+ plurals int4 NOT NULL default '0',
+ formula varchar(128) NOT NULL default '',
+ PRIMARY KEY (locale)
+);
+
+--
+-- Table structure for locales_source
+--
+
+CREATE sequence locales_source_lid_seq;
+
+CREATE TABLE locales_source (
+lid integer DEFAULT nextval('locales_source_lid_seq'::text) NOT NULL,
location varchar(128) NOT NULL default '',
- string text NOT NULL default '',
- da text NOT NULL default '',
- fi text NOT NULL default '',
- fr text NOT NULL default '',
- en text NOT NULL default '',
- es text NOT NULL default '',
- nl text NOT NULL default '',
- no text NOT NULL default '',
- sw text NOT NULL default '',
+ source text NOT NULL,
PRIMARY KEY (lid)
);
--
+-- Table structure for locales_target
+--
+
+CREATE TABLE locales_target (
+ lid int4 NOT NULL default '0',
+ translation text NOT NULL,
+ locale varchar(12) NOT NULL default '',
+ plid int4 NOT NULL default '0',
+ plural int4 NOT NULL default '0',
+ UNIQUE (lid),
+ UNIQUE (locale),
+ UNIQUE (plid),
+ UNIQUE (plural)
+);
+
+--
-- Table structure for table 'menu'
--
@@ -601,7 +625,7 @@ CREATE TABLE users (
changed integer NOT NULL default '0',
status smallint NOT NULL default '0',
timezone varchar(8) default NULL,
- language char(2) NOT NULL default '',
+ language varchar(12) NOT NULL default '',
picture varchar(255) NOT NULL DEFAULT '',
init varchar(64) default '',
data text default '',
@@ -703,6 +727,7 @@ INSERT INTO filters VALUES (2,'filter',1,0);
INSERT INTO filters VALUES (3,'filter',3,0);
INSERT INTO variable (name,value) VALUES ('filter_html_1','i:1;');
+INSERT INTO locales_meta(locale, name, enabled, isdefault) VALUES('en', 'English', '1', '1');
---
--- Functions
diff --git a/database/updates.inc b/database/updates.inc
index be5a59b81..a2d5400df 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -70,7 +70,9 @@ $sql_updates = array(
"2004-08-04" => "update_96",
"2004-08-06" => "update_97",
"2004-08-07" => "update_98",
- "2004-08-09" => "update_99"
+ "2004-08-09" => "update_99",
+ "2004-08-10" => "update_100",
+ "2004-08-11" => "update_101"
);
function update_32() {
@@ -1461,6 +1463,87 @@ function update_99() {
return $ret;
}
+function update_100() {
+
+ $ret = array();
+ if ($GLOBALS["db_type"] == "mysql") {
+ $ret[] = update_sql("CREATE TABLE {locales_source} (
+ lid int(11) NOT NULL auto_increment,
+ location varchar(128) NOT NULL default '',
+ source blob NOT NULL,
+ PRIMARY KEY (lid)
+ )");
+ $ret[] = update_sql("CREATE TABLE {locales_target} (
+ lid int(11) NOT NULL default '0',
+ translation blob NOT NULL,
+ locale varchar(12) NOT NULL default '',
+ plid int(11) NOT NULL default '0',
+ plural int(1) NOT NULL default '0',
+ KEY lid (lid),
+ KEY lang (locale),
+ KEY plid (plid),
+ KEY plural (plural)
+ )");
+ $ret[] = update_sql("INSERT INTO {locales_meta} (locale, name, enabled, isdefault) VALUES ('en', 'English', '1', '1')");
+ $ret[] = update_sql("ALTER TABLE {users} CHANGE language language varchar(12) NOT NULL default ''");
+ }
+ else { // TODO: pgsql support (see database.pgsql for suggestions)
+ }
+
+ return $ret;
+}
+
+function update_101() {
+ include_once 'includes/locale.inc';
+ // get the language columns
+ $result = db_query('SELECT * FROM {locales} LIMIT 1');
+ $fields = array();
+ if (db_num_rows($result)) {
+ $columns = array_keys(db_fetch_array($result));
+ foreach ($columns as $field) {
+ $fields[$field] = 1;
+ }
+
+ // but not the fixed fields
+ unset($fields['lid'], $fields['location'], $fields['string']);
+
+ // insert locales
+ $list = _locale_get_iso639_list();
+ foreach ($fields as $key => $value) {
+ if (db_result(db_query("SELECT COUNT(lid) FROM {locales} WHERE $key != ''"))) {
+ if (isset($list[$key])) {
+ $name = $list[$key][0];
+ if ($key == 'en') {
+ $key = 'en-local';
+ }
+ db_query("INSERT INTO {locales_meta} (locale, name) VALUES ('%s', '%s')", $key, $name);
+ }
+ else {
+ db_query("INSERT INTO {locales_meta} (locale, name) VALUES ('%s', '%s')", $key, $key);
+ }
+ }
+ }
+
+ // get all strings
+ $result = db_query('SELECT * FROM {locales}');
+ while($entry = db_fetch_object($result)) {
+ // insert string if at least one translation exists
+ $test = 'return $entry->'. implode(' == "" && $entry->', array_keys($fields)) .' == "";';
+ if (!eval($test)) {
+ db_query("INSERT INTO {locales_source} (location, source) VALUES ('%s', '%s')", $entry->location, $entry->string);
+ $lid = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE location = '%s' AND source = '%s'", $entry->location, $entry->string));
+ foreach ($fields as $key => $value) {
+ // insert translation if non-empty
+ db_query("INSERT INTO {locales_target} (lid, translation, locale) VALUES (%d, '%s', '%s')", $lid->lid, $entry->$key, $key);
+ }
+ }
+ }
+ }
+
+ $ret = array();
+ $ret[] = update_sql("DROP TABLE {locales}");
+ return $ret;
+}
function update_sql($sql) {
$edit = $_POST["edit"];