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.
16 * @deprecated in Drupal 8.5.0 and will be removed before 9.0.0. It is unused by
17 * Drupal core. Duplicate this function in your own extension if you need its
20 * @see https://www.drupal.org/node/2931188
22 function locale_translation_manual_status() {
23 @trigger_error('locale_translation_manual_status() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. It is unused by Drupal core. Duplicate this function in your own extension if you need its behavior.', E_USER_DEPRECATED);
24 module_load_include('compare.inc', 'locale');
26 // Check the translation status of all translatable projects in all languages.
27 // First we clear the cached list of projects. Although not strictly
28 // necessary, this is helpful in case the project list is out of sync.
29 locale_translation_flush_projects();
30 locale_translation_check_projects();
32 // Execute a batch if required. A batch is only used when remote files
35 return batch_process('admin/reports/translations');
37 return new RedirectResponse(\Drupal::url('locale.translate_status', [], ['absolute' => TRUE]));
41 * Prepares variables for translation status information templates.
43 * Translation status information is displayed per language.
45 * Default template: locale-translate-edit-form-strings.html.twig.
47 * @param array $variables
48 * An associative array containing:
49 * - updates: The projects which have updates.
50 * - not_found: The projects which updates are not found.
52 * @see \Drupal\locale\Form\TranslationStatusForm
54 function template_preprocess_locale_translation_update_info(array &$variables) {
55 foreach ($variables['updates'] as $update) {
56 $variables['modules'][] = $update['name'];
61 * Prepares variables for most recent translation update templates.
63 * Displays the last time we checked for locale update data. In addition to
64 * properly formatting the given timestamp, this function also provides a "Check
65 * manually" link that refreshes the available update and redirects back to the
68 * Default template: locale-translation-last-check.html.twig.
70 * @param array $variables
71 * An associative array containing:
72 * - last: The timestamp when the site last checked for available updates.
74 * @see \Drupal\locale\Form\TranslationStatusForm
76 function template_preprocess_locale_translation_last_check(array &$variables) {
77 $last = $variables['last'];
78 $variables['last_checked'] = ($last != NULL);
79 $variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($last);
80 $variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', [], ['query' => \Drupal::destination()->getAsArray()]));