| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Install, update, and uninstall functions for the Locale module.
 
-  */
 
- use Drupal\Core\Url;
 
- /**
 
-  * Implements hook_install().
 
-  */
 
- function locale_install() {
 
-   // Create the interface translations directory and ensure it's writable.
 
-   if (!$directory = \Drupal::config('locale.settings')->get('translation.path')) {
 
-     $site_path = \Drupal::service('site.path');
 
-     $directory = $site_path . '/files/translations';
 
-     \Drupal::configFactory()->getEditable('locale.settings')->set('translation.path', $directory)->save();
 
-   }
 
-   file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
 
- }
 
- /**
 
-  * Implements hook_uninstall().
 
-  */
 
- function locale_uninstall() {
 
-   $config = \Drupal::config('locale.settings');
 
-   // Delete all JavaScript translation files.
 
-   $locale_js_directory = 'public://' . $config->get('javascript.directory');
 
-   if (is_dir($locale_js_directory)) {
 
-     $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: [];
 
-     foreach ($locale_javascripts as $langcode => $file_suffix) {
 
-       if (!empty($file_suffix)) {
 
-         file_unmanaged_delete($locale_js_directory . '/' . $langcode . '_' . $file_suffix . '.js');
 
-       }
 
-     }
 
-     // Delete the JavaScript translations directory if empty.
 
-     if (!file_scan_directory($locale_js_directory, '/.*/')) {
 
-       drupal_rmdir($locale_js_directory);
 
-     }
 
-   }
 
-   // Clear variables.
 
-   \Drupal::state()->delete('system.javascript_parsed');
 
-   \Drupal::state()->delete('locale.translation.plurals');
 
-   \Drupal::state()->delete('locale.translation.javascript');
 
- }
 
- /**
 
-  * Implements hook_schema().
 
-  */
 
- function locale_schema() {
 
-   $schema['locales_source'] = [
 
-     'description' => 'List of English source strings.',
 
-     'fields' => [
 
-       'lid' => [
 
-         'type' => 'serial',
 
-         'not null' => TRUE,
 
-         'description' => 'Unique identifier of this string.',
 
-       ],
 
-       'source' => [
 
-         'type' => 'text',
 
-         'mysql_type' => 'blob',
 
-         'not null' => TRUE,
 
-         'description' => 'The original string in English.',
 
-       ],
 
-       'context' => [
 
-         'type' => 'varchar_ascii',
 
-         'length' => 255,
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'The context this string applies to.',
 
-       ],
 
-       'version' => [
 
-         'type' => 'varchar_ascii',
 
-         'length' => 20,
 
-         'not null' => TRUE,
 
-         'default' => 'none',
 
-         'description' => 'Version of Drupal where the string was last used (for locales optimization).',
 
-       ],
 
-     ],
 
-     'primary key' => ['lid'],
 
-     'indexes' => [
 
-       'source_context' => [['source', 30], 'context'],
 
-     ],
 
-   ];
 
-   $schema['locales_target'] = [
 
-     'description' => 'Stores translated versions of strings.',
 
-     'fields' => [
 
-       'lid' => [
 
-         'type' => 'int',
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-         'description' => 'Source string ID. References {locales_source}.lid.',
 
-       ],
 
-       'translation' => [
 
-         'type' => 'text',
 
-         'mysql_type' => 'blob',
 
-         'not null' => TRUE,
 
-         'description' => 'Translation string value in this language.',
 
-       ],
 
-       'language' => [
 
-         'type' => 'varchar_ascii',
 
-         'length' => 12,
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'Language code. References {language}.langcode.',
 
-       ],
 
-       'customized' => [
 
-         'type' => 'int',
 
-         'not null' => TRUE,
 
-         // LOCALE_NOT_CUSTOMIZED
 
-         'default' => 0,
 
-         'description' => 'Boolean indicating whether the translation is custom to this site.',
 
-       ],
 
-     ],
 
-     'primary key' => ['language', 'lid'],
 
-     'foreign keys' => [
 
-       'locales_source' => [
 
-         'table' => 'locales_source',
 
-         'columns' => ['lid' => 'lid'],
 
-       ],
 
-     ],
 
-     'indexes' => [
 
-       'lid' => ['lid'],
 
-     ],
 
-   ];
 
-   $schema['locales_location'] = [
 
-     'description' => 'Location information for source strings.',
 
-     'fields' => [
 
-       'lid' => [
 
-         'type' => 'serial',
 
-         'not null' => TRUE,
 
-         'description' => 'Unique identifier of this location.',
 
-       ],
 
-       'sid' => [
 
-         'type' => 'int',
 
-         'not null' => TRUE,
 
-         'description' => 'Unique identifier of this string.',
 
-       ],
 
-       'type' => [
 
-         'type' => 'varchar_ascii',
 
-         'length' => 50,
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'The location type (file, config, path, etc).',
 
-       ],
 
-       'name' => [
 
-         'type' => 'varchar',
 
-         'length' => 255,
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'Type dependent location information (file name, path, etc).',
 
-       ],
 
-       'version' => [
 
-         'type' => 'varchar_ascii',
 
-         'length' => 20,
 
-         'not null' => TRUE,
 
-         'default' => 'none',
 
-         'description' => 'Version of Drupal where the location was found.',
 
-       ],
 
-     ],
 
-     'primary key' => ['lid'],
 
-     'foreign keys' => [
 
-       'locales_source' => [
 
-         'table' => 'locales_source',
 
-         'columns' => ['sid' => 'lid'],
 
-       ],
 
-     ],
 
-     'indexes' => [
 
-       'string_id' => ['sid'],
 
-       'string_type' => ['sid', 'type'],
 
-     ],
 
-   ];
 
-   $schema['locale_file'] = [
 
-     'description' => 'File import status information for interface translation files.',
 
-     'fields' => [
 
-       'project' => [
 
-         'type' => 'varchar_ascii',
 
-         'length' => '255',
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'A unique short name to identify the project the file belongs to.',
 
-       ],
 
-       'langcode' => [
 
-         'type' => 'varchar_ascii',
 
-         'length' => '12',
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'Language code of this translation. References {language}.langcode.',
 
-       ],
 
-       'filename' => [
 
-         'type' => 'varchar',
 
-         'length' => 255,
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'Filename of the imported file.',
 
-       ],
 
-       'version' => [
 
-         'type' => 'varchar',
 
-         'length' => '128',
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'Version tag of the imported file.',
 
-       ],
 
-       'uri' => [
 
-         'type' => 'varchar',
 
-         'length' => 255,
 
-         'not null' => TRUE,
 
-         'default' => '',
 
-         'description' => 'URI of the remote file, the resulting local file or the locally imported file.',
 
-       ],
 
-       'timestamp' => [
 
-         'type' => 'int',
 
-         'not null' => FALSE,
 
-         'default' => 0,
 
-         'description' => 'Unix timestamp of the imported file.',
 
-       ],
 
-       'last_checked' => [
 
-         'type' => 'int',
 
-         'not null' => FALSE,
 
-         'default' => 0,
 
-         'description' => 'Unix timestamp of the last time this translation was confirmed to be the most recent release available.',
 
-       ],
 
-     ],
 
-     'primary key' => ['project', 'langcode'],
 
-   ];
 
-   return $schema;
 
- }
 
- /**
 
-  * Implements hook_requirements().
 
-  */
 
- function locale_requirements($phase) {
 
-   $requirements = [];
 
-   if ($phase == 'runtime') {
 
-     $available_updates = [];
 
-     $untranslated = [];
 
-     $languages = locale_translatable_language_list();
 
-     if ($languages) {
 
-       // Determine the status of the translation updates per language.
 
-       $status = locale_translation_get_status();
 
-       if ($status) {
 
-         foreach ($status as $project) {
 
-           foreach ($project as $langcode => $project_info) {
 
-             if (empty($project_info->type)) {
 
-               $untranslated[$langcode] = $languages[$langcode]->getName();
 
-             }
 
-             elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) {
 
-               $available_updates[$langcode] = $languages[$langcode]->getName();
 
-             }
 
-           }
 
-         }
 
-         if ($available_updates || $untranslated) {
 
-           if ($available_updates) {
 
-             $requirements['locale_translation'] = [
 
-               'title' => 'Translation update status',
 
-               'value' => \Drupal::l(t('Updates available'), new Url('locale.translate_status')),
 
-               'severity' => REQUIREMENT_WARNING,
 
-               'description' => t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => implode(', ', $available_updates), ':updates' => \Drupal::url('locale.translate_status')]),
 
-             ];
 
-           }
 
-           else {
 
-             $requirements['locale_translation'] = [
 
-               'title' => 'Translation update status',
 
-               'value' => t('Missing translations'),
 
-               'severity' => REQUIREMENT_INFO,
 
-               'description' => t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => implode(', ', $untranslated), ':updates' => \Drupal::url('locale.translate_status')]),
 
-             ];
 
-           }
 
-         }
 
-         else {
 
-           $requirements['locale_translation'] = [
 
-             'title' => 'Translation update status',
 
-             'value' => t('Up to date'),
 
-             'severity' => REQUIREMENT_OK,
 
-           ];
 
-         }
 
-       }
 
-       else {
 
-         $requirements['locale_translation'] = [
 
-           'title' => 'Translation update status',
 
-           'value' => \Drupal::l(t('Can not determine status'), new Url('locale.translate_status')),
 
-           'severity' => REQUIREMENT_WARNING,
 
-           'description' => t('No translation status is available. See the <a href=":updates">Available translation updates</a> page for more information.', [':updates' => \Drupal::url('locale.translate_status')]),
 
-         ];
 
-       }
 
-     }
 
-   }
 
-   return $requirements;
 
- }
 
- /**
 
-  * Delete translation status data in state.
 
-  */
 
- function locale_update_8300() {
 
-   // Delete the old translation status data, it will be rebuilt and stored in
 
-   // the new key value collection.
 
-   \Drupal::state()->delete('locale.translation_status');
 
- }
 
 
  |