function locale_schema

Same name and namespace in other branches
  1. 10 core/modules/locale/locale.install \locale_schema()
  2. 11.x core/modules/locale/locale.install \locale_schema()
  3. 9 core/modules/locale/locale.install \locale_schema()
  4. 8.9.x core/modules/locale/locale.install \locale_schema()
  5. 7.x modules/locale/locale.install \locale_schema()

Implements hook_schema().

File

core/modules/locale/locale.install, line 71

Code

function locale_schema() : Schema {
  $locales_source = new Table(name: 'locales_source', description: 'List of English source strings.', columns: [
    Column::serial(name: 'lid', description: 'Unique identifier of this string.'),
    Column::create(type: ColumnType::Text, name: 'source', description: 'The original string in English.', notNull: TRUE, dbSpecificExtra: [
      'mysql' => [
        'mysql_type' => 'blob',
      ],
    ]),
    Column::varcharAscii(name: 'context', description: 'The context this string applies to.', length: 255, notNull: TRUE, default: new StringValue('')),
    Column::varcharAscii(name: 'version', description: 'Version of Drupal where the string was last used (for locales optimization).', length: 20, notNull: TRUE, default: new StringValue('none')),
  ], primaryKey: new PrimaryKey([
    'lid',
  ]), indexes: [
    new Index(name: 'source_context', columns: [
      [
        'source',
        30,
      ],
      'context',
    ]),
  ]);
  $locales_target = new Table(name: 'locales_target', description: 'Stores translated versions of strings.', columns: [
    Column::int(name: 'lid', description: 'Source string ID. References {locales_source}.lid.', notNull: TRUE, default: new IntValue(0)),
    Column::create(type: ColumnType::Text, name: 'translation', description: 'Translation string value in this language.', notNull: TRUE, dbSpecificExtra: [
      'mysql' => [
        'mysql_type' => 'blob',
      ],
    ]),
    Column::varcharAscii(name: 'language', description: 'Language code. References {language}.langcode.', length: 12, notNull: TRUE, default: new StringValue('')),
    Column::int(name: 'customized', description: 'Boolean indicating whether the translation is custom to this site.', notNull: TRUE, default: new IntValue(0)),
  ], primaryKey: new PrimaryKey([
    'language',
    'lid',
  ]), indexes: [
    new Index(name: 'lid', columns: [
      'lid',
    ]),
  ], foreignKeys: [
    new ForeignKey(name: 'locales_source', foreignTable: 'locales_source', columns: [
      'lid',
    ], foreignColumns: [
      'lid',
    ]),
  ]);
  $locales_location = new Table(name: 'locales_location', description: 'Location information for source strings.', columns: [
    Column::serial(name: 'lid', description: 'Unique identifier of this location.'),
    Column::int(name: 'sid', description: 'Unique identifier of this string.', notNull: TRUE),
    Column::varcharAscii(name: 'type', description: 'The location type (file, config, path, etc).', length: 50, notNull: TRUE, default: new StringValue('')),
    Column::varchar(name: 'name', description: 'Type dependent location information (file name, path, etc).', length: 255, notNull: TRUE, default: new StringValue('')),
    Column::varcharAscii(name: 'version', description: 'Version of Drupal where the location was found.', length: 20, notNull: TRUE, default: new StringValue('none')),
  ], primaryKey: new PrimaryKey([
    'lid',
  ]), indexes: [
    new Index(name: 'string_type', columns: [
      'sid',
      'type',
    ]),
    new Index(name: 'type_name', columns: [
      'type',
      'name',
    ]),
  ], foreignKeys: [
    new ForeignKey(name: 'locales_source', foreignTable: 'locales_source', columns: [
      'sid',
    ], foreignColumns: [
      'lid',
    ]),
  ]);
  $locale_file = new Table(name: 'locale_file', description: 'File import status information for interface translation files.', columns: [
    Column::varcharAscii(name: 'project', description: 'A unique short name to identify the project the file belongs to.', length: 255, notNull: TRUE, default: new StringValue('')),
    Column::varcharAscii(name: 'langcode', description: 'Language code of this translation. References {language}.langcode.', length: 12, notNull: TRUE, default: new StringValue('')),
    Column::varchar(name: 'filename', description: 'Filename of the imported file.', length: 255, notNull: TRUE, default: new StringValue('')),
    Column::varchar(name: 'version', description: 'Version tag of the imported file.', length: 128, notNull: TRUE, default: new StringValue('')),
    Column::varchar(name: 'uri', description: 'URI of the remote file, the resulting local file or the locally imported file.', length: 255, notNull: TRUE, default: new StringValue('')),
    Column::int(name: 'timestamp', description: 'Unix timestamp of the imported file.', size: ColumnSize::Big, notNull: FALSE, default: new IntValue(0)),
    Column::varcharAscii(name: 'hash', description: 'The hash of the imported file.', length: 32, notNull: TRUE, default: new StringValue('')),
    Column::int(name: 'last_checked', description: 'Unix timestamp of the last time this translation was confirmed to be the most recent release available.', size: ColumnSize::Big, notNull: FALSE, default: new IntValue(0)),
  ], primaryKey: new PrimaryKey([
    'project',
    'langcode',
  ]));
  return new Schema(type: SchemaDefinitionType::Module, name: 'locale', tables: [
    $locales_source,
    $locales_target,
    $locales_location,
    $locale_file,
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.