function locale_translation_status_save in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/locale/locale.module \locale_translation_status_save()
Saves the status of translation sources in static cache.
Parameters
string $project: Machine readable project name.
string $langcode: Language code.
string $type: Type of data to be stored.
array $data: File object also containing timestamp when the translation is last updated.
4 calls to locale_translation_status_save()
- locale_translation_batch_fetch_download in core/
modules/ locale/ locale.batch.inc - Implements callback_batch_operation().
- locale_translation_batch_fetch_import in core/
modules/ locale/ locale.batch.inc - Implements callback_batch_operation().
- locale_translation_batch_status_check in core/
modules/ locale/ locale.batch.inc - Implements callback_batch_operation().
- locale_translation_check_projects_local in core/
modules/ locale/ locale.compare.inc - Check and store the status and timestamp of local po files.
File
- core/
modules/ locale/ locale.module, line 919 - Enables the translation of the user interface to languages other than English.
Code
function locale_translation_status_save($project, $langcode, $type, $data) {
// Follow-up issue: https://www.drupal.org/node/1842362.
// Split status storage per module/language and expire individually. This will
// improve performance for large sites.
// Load the translation status or build it if not already available.
module_load_include('translation.inc', 'locale');
$status = locale_translation_get_status();
if (empty($status)) {
$projects = locale_translation_get_projects(array(
$project,
));
if (isset($projects[$project])) {
$status[$project][$langcode] = locale_translation_source_build($projects[$project], $langcode);
}
}
// Merge the new status data with the existing status.
if (isset($status[$project][$langcode])) {
switch ($type) {
case LOCALE_TRANSLATION_REMOTE:
case LOCALE_TRANSLATION_LOCAL:
// Add the source data to the status array.
$status[$project][$langcode]->files[$type] = $data;
// Check if this translation is the most recent one. Set timestamp and
// data type of the most recent translation source.
if (isset($data->timestamp) && $data->timestamp) {
if ($data->timestamp > $status[$project][$langcode]->timestamp) {
$status[$project][$langcode]->timestamp = $data->timestamp;
$status[$project][$langcode]->last_checked = REQUEST_TIME;
$status[$project][$langcode]->type = $type;
}
}
break;
case LOCALE_TRANSLATION_CURRENT:
$data->last_checked = REQUEST_TIME;
$status[$project][$langcode]->timestamp = $data->timestamp;
$status[$project][$langcode]->last_checked = $data->last_checked;
$status[$project][$langcode]->type = $type;
locale_translation_update_file_history($data);
break;
}
\Drupal::state()
->set('locale.translation_status', $status);
\Drupal::state()
->set('locale.translation_last_checked', REQUEST_TIME);
}
}