Removing translation directories
[project/i18n.git] / i18n.install
CommitLineData
22bc9319 1<?php
22bc9319 2/**
a9c3be2f
JR
3 * Implementation of hook_schema().
4 */
5function i18n_schema() {
a9c3be2f
JR
6 $schema['i18n_variable'] = array(
7 'description' => t('Multilingual variables.'),
8 'fields' => array(
9 'name' => array(
10 'description' => t('The name of the variable.'),
11 'type' => 'varchar',
12 'length' => 128,
13 'not null' => TRUE,
14 'default' => ''),
15 'language' => array(
16 'description' => t('The language of the variable.'),
17 'type' => 'varchar',
18 'length' => 12,
19 'not null' => TRUE,
20 'default' => ''),
21 'value' => array(
22 'description' => t('The value of the variable.'),
23 'type' => 'text',
24 'not null' => TRUE,
25 'size' => 'big'),
26 ),
27 'primary key' => array('name', 'language'),
28 );
29 return $schema;
30}
31
32/**
22bc9319
JR
33 * Set language field in its own table
34 * Do not drop node.language now, just in case
35 * TO-DO: Drop old tables, fields
36 */
22bc9319 37function i18n_install() {
a9c3be2f
JR
38 // Create database tables
39 drupal_install_schema('i18n');
afcc0a25 40 // Set module weight for it to run after core modules
818652bd 41 db_query("UPDATE {system} SET weight = 10 WHERE name = 'i18n' AND type = 'module'");
22bc9319 42}
98e35ee4
JR
43
44/**
45 * Drupal 4.7 updates
46 **/
22bc9319
JR
47function i18n_update_1() {
48 $items = array();
49 $items[] = update_sql("ALTER TABLE {i18n_node} ADD language VARCHAR(12)");
50 $items[] = update_sql("UPDATE {i18n_node} i INNER JOIN {node} n ON i.nid = n.nid SET i.language = n.language ");
51 $items[] = update_sql("INSERT INTO {i18n_node}(nid,language) SELECT n.nid, n.language FROM {node} n LEFT JOIN {i18n_node} i ON n.nid = i.nid WHERE n.language != '' AND i.nid IS NULL");
52 return $items;
53}
54
55function i18n_update_2() {
56 $items = array();
57 $items[] = update_sql("ALTER TABLE {term_data} ADD trid int(10) unsigned NOT NULL default '0'");
58 $items[] = update_sql("UPDATE {term_data} t INNER JOIN {i18n_taxonomy_term} i ON i.tid = t.tid SET t.trid = i.trid");
59 return $items;
60}
61
62function i18n_update_3(){
63 $items = array();
64 $items[] = update_sql("ALTER TABLE {i18n_node} MODIFY COLUMN trid INTEGER UNSIGNED NOT NULL default '0', DROP PRIMARY KEY, ADD PRIMARY KEY(nid)");
65 $items[] = update_sql("ALTER TABLE {term_data} MODIFY COLUMN trid INTEGER UNSIGNED NOT NULL default '0', DROP PRIMARY KEY, ADD PRIMARY KEY(tid)");
66 return $items;
67}
68
69function i18n_update_4(){
70 $items[] = update_sql("CREATE TABLE {i18n_variable} (
71 name varchar(48) NOT NULL default '',
72 language varchar(12) NOT NULL default '',
73 value longtext NOT NULL,
74 PRIMARY KEY (name, language)
75 )");
76 return $items;
77}
afcc0a25
JR
78
79/**
80 * Drupal 5 updates
81 */
82// Multilingual menu items
83function i18n_update_5(){
84 $items[] = update_sql("ALTER TABLE {menu} ADD language VARCHAR(12) NOT NULL default ''");
85 return $items;
86}
87// Module weithgts
88function i18n_update_6(){
89 // Old module weights. Caused some trouble with other modules.
90}
91// Redefinition of module weights
92function i18n_update_7(){
93 $items[] = update_sql("UPDATE {system} SET weight = -10 WHERE name = 'i18n' AND type = 'module'");
94 $items[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'translation' AND type = 'module'");
95 return $items;
96}
97// Update tables to utf8
98function i18n_update_8(){
99 return _system_update_utf8(array('i18n_variable'));
100}
101
102/**
103 * Drupal 6 updates
e562cb3d 104 */
818652bd
JR
105function i18n_update_9() {
106 // Update content type settings
107 foreach (array_keys(node_get_types()) as $type) {
108 if (variable_get('i18n_node_'.$type, 0)) {
109 variable_set('language_content_type_'.$type, TRANSLATION_ENABLED);
110 }
111 }
e562cb3d
JR
112 // General language settings
113 if (variable_get('i18n_browser', 0)) {
114 variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
115 } else {
116 variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH_DEFAULT);
117 }
818652bd
JR
118 // Set module weight for it to run after core modules
119 $items[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'i18n' AND type = 'module'");
818652bd 120 // Move node language and trid into node table
e562cb3d
JR
121 $items[] = update_sql("UPDATE {node} n INNER JOIN {i18n_node} i ON n.nid = i.nid SET n.language = i.language, n.tnid = i.trid");
122
123 return $items;
124}
818652bd 125
e562cb3d
JR
126/**
127 * Drupal 6 clean up. To uncomment after making sure all previous updates work
128 */
129/*
130function i18n_update_10() {
131 // Drop old tables
132 $items[] = update_sql("DROP TABLE {i18n_node}");
133
134 // Delete variables. Most settings will be now handled by Drupal core.
135 variable_del('i18n_allow');
136 variable_del('i18n_browser');
137 variable_del('i18n_content');
138 variable_del('i18n_keep');
139 variable_del('i18n_multi');
140 variable_del('i18n_interface');
141 variable_del('i18n_default');
142 variable_del('i18n_supported_langs');
143 variable_del('i18n_translation_links');
144 variable_del('i18n_translation_node_links');
818652bd 145 return $items;
e562cb3d
JR
146}
147*/