summaryrefslogtreecommitdiffstats
path: root/modules/locale/locale.install
blob: ecba859167c31c8a52301d9750a190d047d84aea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
// $Id$

/**
 * Implementation of hook_install().
 */
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} (
        locale varchar(12) NOT NULL default '',
        name varchar(64) NOT NULL default '',
        enabled int NOT NULL default '0',
        isdefault int NOT NULL default '0',
        plurals int NOT NULL default '0',
        formula varchar(128) NOT NULL default '',
        PRIMARY KEY (locale)
      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");

      db_query("CREATE TABLE {locales_source} (
        lid int NOT NULL auto_increment,
        location varchar(255) NOT NULL default '',
        source blob NOT NULL,
        PRIMARY KEY (lid),
        KEY source (source(30))
      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");

      db_query("CREATE TABLE {locales_target} (
        lid int NOT NULL default '0',
        translation blob NOT NULL,
        locale varchar(12) NOT NULL default '',
        plid int NOT NULL default '0',
        plural int NOT NULL default '0',
        KEY lid (lid),
        KEY lang (locale),
        KEY plid (plid),
        KEY plural (plural)
      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;

    case 'pgsql':
      db_query("CREATE TABLE {locales_meta} (
        locale varchar(12) NOT NULL default '',
        name varchar(64) NOT NULL default '',
        enabled int NOT NULL default '0',
        isdefault int NOT NULL default '0',
        plurals int NOT NULL default '0',
        formula varchar(128) NOT NULL default '',
        PRIMARY KEY (locale)
      )");

      db_query("CREATE TABLE {locales_source} (
        lid serial,
        location varchar(255) NOT NULL default '',
        source text NOT NULL,
        PRIMARY KEY (lid)
      )");

      db_query("CREATE TABLE {locales_target} (
        lid int NOT NULL default '0',
        translation text NOT NULL,
        locale varchar(12) NOT NULL default '',
        plid int NOT NULL default '0',
        plural int NOT NULL default '0'
      )");
      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')");
}

/**
 * Implementation of hook_uninstall().
 */
function locale_uninstall() {
  db_query('DROP TABLE {locales_meta}');
  db_query('DROP TABLE {locales_source}');
  db_query('DROP TABLE {locales_target}');
}