1 locale.install locale_schema()

Implements hook_schema().

File

core/modules/locale/locale.install, line 99
Install, update and uninstall functions for the locale module.

Code

function locale_schema() {
  $schema['locales_source'] = array(
    'description' => 'List of English source strings.',
    'fields' => array(
      'lid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Unique identifier of this string.',
      ),
      'location' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => 'Backdrop path in case of online discovered translations or file path in case of imported strings.',
      ),
      'source' => array(
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'The original string in English.',
      ),
      'context' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The context this string applies to.',
      ),
      'version' => array(
        'type' => 'varchar',
        'length' => 20,
        'not null' => TRUE,
        'default' => 'none',
        'description' => 'Version of Backdrop, where the string was last used (for locales optimization).',
      ),
    ),
    'primary key' => array('lid'),
    'indexes' => array(
      'source_context' => array(array('source', 30), 'context'),
    ),
  );

  $schema['locales_target'] = array(
    'description' => 'Stores translated versions of strings.',
    'fields' => array(
      'lid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Source string ID. References {locales_source}.lid.',
      ),
      'translation' => array(
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'Translation string value in this language.',
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Language code from the language.settings config file',
      ),
      'plid' => array(
        'type' => 'int',
        'not null' => TRUE, // This should be NULL for no referenced string, not zero.
        'default' => 0,
        'description' => 'Parent lid (lid of the previous string in the plural chain) in case of plural strings. References {locales_source}.lid.',
      ),
      'plural' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Plural index number in case of plural strings.',
      ),
    ),
    'primary key' => array('language', 'lid', 'plural'),
    'foreign keys' => array(
      'locales_source' => array(
        'table' => 'locales_source',
        'columns' => array('lid' => 'lid'),
      ),
    ),
    'indexes' => array(
      'lid' => array('lid'),
      'plid' => array('plid'),
      'plural' => array('plural'),
    ),
  );

  return $schema;
}