function LocaleFetch::batchVersionCheck
Same name and namespace in other branches
- 11.x 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 273
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;
}
$source = $this->localeSource
->loadSource($project, $langcode);
if ($locale_project->version == $source->version) {
return;
}
$this->localeSource
->deleteSources([
$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.