5 * Interface translation summary, editing and deletion user interfaces.
9 use Symfony\Component\HttpFoundation\RedirectResponse;
12 * Page callback: Checks for translation updates and displays the status.
14 * Manually checks the translation status without the use of cron.
18 function locale_translation_manual_status() {
19 module_load_include('compare.inc', 'locale');
21 // Check the translation status of all translatable projects in all languages.
22 // First we clear the cached list of projects. Although not strictly
23 // necessary, this is helpful in case the project list is out of sync.
24 locale_translation_flush_projects();
25 locale_translation_check_projects();
27 // Execute a batch if required. A batch is only used when remote files
30 return batch_process('admin/reports/translations');
32 return new RedirectResponse(\Drupal::url('locale.translate_status', [], ['absolute' => TRUE]));
36 * Prepares variables for translation status information templates.
38 * Translation status information is displayed per language.
40 * Default template: locale-translate-edit-form-strings.html.twig.
42 * @param array $variables
43 * An associative array containing:
44 * - updates: The projects which have updates.
45 * - not_found: The projects which updates are not found.
47 * @see \Drupal\locale\Form\TranslationStatusForm
49 function template_preprocess_locale_translation_update_info(array &$variables) {
50 foreach ($variables['updates'] as $update) {
51 $variables['modules'][] = $update['name'];
56 * Prepares variables for most recent translation update templates.
58 * Displays the last time we checked for locale update data. In addition to
59 * properly formatting the given timestamp, this function also provides a "Check
60 * manually" link that refreshes the available update and redirects back to the
63 * Default template: locale-translation-last-check.html.twig.
65 * @param array $variables
66 * An associative array containing:
67 * - last: The timestamp when the site last checked for available updates.
69 * @see \Drupal\locale\Form\TranslationStatusForm
71 function template_preprocess_locale_translation_last_check(array &$variables) {
72 $last = $variables['last'];
73 $variables['last_checked'] = ($last != NULL);
74 $variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($last);
75 $variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', [], ['query' => \Drupal::destination()->getAsArray()]));