2
// $Id: i18nstrings.install,v 1.2.2.10 2009/01/14 18:20:08 snpower Exp $
6
* Installation file for i18nstrings module.
9
function i18nstrings_install() {
10
// Create database tables.
11
drupal_install_schema('i18nstrings');
13
// Set module weight for it to run after core modules.
14
db_query("UPDATE {system} SET weight = 10 WHERE name = 'i18nstrings' AND type = 'module'");
18
// Add a field to track whether a translation needs updating.
19
db_add_field($ret, 'locales_target', 'status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
21
// Add custom index to locales_source table.
22
db_add_index($ret, 'locales_source', 'textgroup_location', array(array('textgroup', 30), 'location'));
25
function i18nstrings_uninstall() {
28
// Create database tables.
29
drupal_uninstall_schema('i18nstrings');
30
// @TODO locale table cleanup, think about it.
31
// Should we drop all strings for groups other than 'default' ?
34
db_drop_field($ret, 'locales_target', 'status');
36
db_drop_index($ret, 'locales_source', 'textgroup_location');
40
* Implementation of hook_schema().
42
function i18nstrings_schema() {
43
$schema['i18n_strings'] = array(
44
'description' => t('Metadata for source strings.'),
50
'description' => t('Source string ID. References {locales_source}.lid.'),
56
'description' => t('Object ID.'),
63
'description' => t('Object type for this string.'),
69
'default' => 'default',
70
'description' => t('Object property for this string.'),
73
'primary key' => array('lid'),
79
* Implementation of hook_schema_alter().
81
function i18nstrings_schema_alter(&$schema) {
82
// Add index for textgroup and location to {locales_source}.
83
$schema['locales_source']['indexes']['textgroup_location'] = array(array('textgroup', 30), 'location');
84
// Add field for tracking whether translations need updating.
85
$schema['locales_target']['status'] = array(
86
'description' => t('A boolean indicating whether this translation needs to be updated.'),
94
* Update from 5.x version
97
function i18nstrings_update_5900() {
98
i18nstrings_install();
99
// Mark next update to be skipped
100
variable_set('i18nstrings_update_skip', 1);
106
* Drupal 6 update. Change field name, 'oid' was psql reserved name.
108
* ALTER TABLE `drupal6_i18n`.`i18n_strings` CHANGE COLUMN `oid` `objectid` INTEGER NOT NULL DEFAULT 0;
110
function i18nstrings_update_6001() {
112
if (!variable_get('i18nstrings_update_skip', 0)) {
113
db_change_field($ret, 'i18n_strings', 'oid', 'objectid', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
115
variable_del('i18nstrings_update_skip');
121
* Add index to {locales_source}.
123
function i18nstrings_update_6002() {
125
db_add_index($ret, 'locales_source', 'textgroup_location', array(array('textgroup', 30), 'location'));
130
* Create i18n_strings_status schema.
131
* Add a field to track whether a translation needs updating.
133
function i18nstrings_update_6003() {
135
db_add_field($ret, 'locales_target', 'status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));