function _install_prepare_import
Same name in other branches
- 9 core/includes/install.core.inc \_install_prepare_import()
- 8.9.x core/includes/install.core.inc \_install_prepare_import()
- 11.x 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 1795
Code
function _install_prepare_import($langcodes, $server_pattern) {
$module_handler = \Drupal::moduleHandler();
$module_handler->loadInclude('locale', 'inc', 'locale.bulk');
$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. Custom translation files may not have a
// version number.
if (isset($matches[1]) && ($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_handler->loadInclude('locale', 'inc', 'locale.compare');
// 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,
]);
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.