function LocaleFetch::batchVersionCheck
Same name and namespace in other branches
- main core/modules/locale/src/LocaleFetch.php \Drupal\locale\LocaleFetch::batchVersionCheck()
Implements callback_batch_operation().
Checks for changed project versions, and cleans-up data from the old version. For example when a module is updated. This will make the translation import system use translations that match the current version.
Parameters
string $project: Machine name of the project for which to check the translation status.
string $langcode: Language code of the language for which to check the translation.
array|\ArrayAccess $context: The batch context.
File
-
core/
modules/ locale/ src/ LocaleFetch.php, line 281
Class
- LocaleFetch
- Provides the locale fetch services.
Namespace
Drupal\localeCode
public function batchVersionCheck(string $project, string $langcode, array|\ArrayAccess &$context) : void {
$locale_project = $this->localeProjectRepository
->getMultiple([
$project,
])[$project] ?? NULL;
if (!$locale_project instanceof LocaleTranslatableProject) {
return;
}
// @todo Replace this as part of locale status function refactoring.
// https://www.drupal.org/project/drupal/issues/2831617
$status = \Drupal::keyValue('locale.translation_status')->get($project);
if (!isset($status[$langcode])) {
return;
}
if ($locale_project->version == $status[$langcode]->version) {
return;
}
locale_translation_status_delete_projects([
$project,
]);
$this->localeFileManager
->deleteTranslationFiles([
$project,
]);
$context['message'] = $this->t('Checked version of %project.', [
'%project' => $project,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.