_install_prepare_import

_install_prepare_import($langcodes, $server_pattern)

Tells the translation import process that Drupal core is installed.

Parameters

array $langcodes: Language codes used for the translations.

string $server_pattern: Server access pattern (to replace language code, version number, etc. in).

File

core/includes/install.core.inc, line 1667
API functions for installing Drupal.

Code

function _install_prepare_import($langcodes, $server_pattern) {
  \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
  $matches = array();

  foreach ($langcodes as $langcode) {
    // Get the translation files located in the translations directory.
    $files = locale_translate_get_interface_translation_files(array('drupal'), array($langcode));
    // Pick the first file which matches the language, if any.
    $file = reset($files);
    if (is_object($file)) {
      $filename = $file->filename;
      preg_match('/drupal-([0-9a-z\.-]+)\.' . $langcode . '\.po/', $filename, $matches);
      // Get the version information.
      if ($version = $matches[1]) {
        $info = _install_get_version_info($version);
        // Picking the first file does not necessarily result in the right file. So
        // we check if at least the major version number is available.
        if ($info['major']) {
          $core = $info['major'] . '.x';
          $data = array(
            'name' => 'drupal',
            'project_type' => 'module',
            'core' => $core,
            'version' => $version,
            'server_pattern' => $server_pattern,
            'status' => 1,
          );
          \Drupal::service('locale.project')->set($data['name'], $data);
          module_load_include('compare.inc', 'locale');
          locale_translation_check_projects_local(array('drupal'), array($langcode));
        }
      }
    }
  }
}
doc_Drupal
2016-10-29 09:57:14
Comments
Leave a Comment

Please login to continue.