function _install_prepare_import in Drupal 8
Same name and namespace in other branches
- 9 core/includes/install.core.inc \_install_prepare_import()
- 10 core/includes/install.core.inc \_install_prepare_import()
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).
1 string reference to '_install_prepare_import'
- install_import_translations in core/
includes/ install.core.inc - Imports languages via a batch process during installation.
File
- core/
includes/ install.core.inc, line 1763 - API functions for installing Drupal.
Code
function _install_prepare_import($langcodes, $server_pattern) {
\Drupal::moduleHandler()
->loadInclude('locale', 'bulk.inc');
$matches = [];
foreach ($langcodes as $langcode) {
// Get the translation files located in the translations directory.
$files = locale_translate_get_interface_translation_files([
'drupal',
], [
$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 = [
'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');
// Reset project information static cache so that it uses the data
// set above.
locale_translation_clear_cache_projects();
locale_translation_check_projects_local([
'drupal',
], [
$langcode,
]);
}
}
}
}
}