Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /**
|
Chris@0
|
4 * @file
|
Chris@0
|
5 * Interface translation summary, editing and deletion user interfaces.
|
Chris@0
|
6 */
|
Chris@0
|
7
|
Chris@0
|
8 use Drupal\Core\Url;
|
Chris@0
|
9 use Symfony\Component\HttpFoundation\RedirectResponse;
|
Chris@0
|
10
|
Chris@0
|
11 /**
|
Chris@0
|
12 * Page callback: Checks for translation updates and displays the status.
|
Chris@0
|
13 *
|
Chris@0
|
14 * Manually checks the translation status without the use of cron.
|
Chris@0
|
15 *
|
Chris@14
|
16 * @deprecated in Drupal 8.5.0 and will be removed before 9.0.0. It is unused by
|
Chris@14
|
17 * Drupal core. Duplicate this function in your own extension if you need its
|
Chris@14
|
18 * behavior.
|
Chris@14
|
19 *
|
Chris@14
|
20 * @see https://www.drupal.org/node/2931188
|
Chris@0
|
21 */
|
Chris@0
|
22 function locale_translation_manual_status() {
|
Chris@14
|
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);
|
Chris@0
|
24 module_load_include('compare.inc', 'locale');
|
Chris@0
|
25
|
Chris@0
|
26 // Check the translation status of all translatable projects in all languages.
|
Chris@0
|
27 // First we clear the cached list of projects. Although not strictly
|
Chris@0
|
28 // necessary, this is helpful in case the project list is out of sync.
|
Chris@0
|
29 locale_translation_flush_projects();
|
Chris@0
|
30 locale_translation_check_projects();
|
Chris@0
|
31
|
Chris@0
|
32 // Execute a batch if required. A batch is only used when remote files
|
Chris@0
|
33 // are checked.
|
Chris@0
|
34 if (batch_get()) {
|
Chris@0
|
35 return batch_process('admin/reports/translations');
|
Chris@0
|
36 }
|
Chris@18
|
37 return new RedirectResponse(Url::fromRoute('locale.translate_status', [], ['absolute' => TRUE])->toString());
|
Chris@0
|
38 }
|
Chris@0
|
39
|
Chris@0
|
40 /**
|
Chris@0
|
41 * Prepares variables for translation status information templates.
|
Chris@0
|
42 *
|
Chris@0
|
43 * Translation status information is displayed per language.
|
Chris@0
|
44 *
|
Chris@0
|
45 * Default template: locale-translate-edit-form-strings.html.twig.
|
Chris@0
|
46 *
|
Chris@0
|
47 * @param array $variables
|
Chris@0
|
48 * An associative array containing:
|
Chris@0
|
49 * - updates: The projects which have updates.
|
Chris@0
|
50 * - not_found: The projects which updates are not found.
|
Chris@0
|
51 *
|
Chris@0
|
52 * @see \Drupal\locale\Form\TranslationStatusForm
|
Chris@0
|
53 */
|
Chris@0
|
54 function template_preprocess_locale_translation_update_info(array &$variables) {
|
Chris@0
|
55 foreach ($variables['updates'] as $update) {
|
Chris@0
|
56 $variables['modules'][] = $update['name'];
|
Chris@0
|
57 }
|
Chris@0
|
58 }
|
Chris@0
|
59
|
Chris@0
|
60 /**
|
Chris@0
|
61 * Prepares variables for most recent translation update templates.
|
Chris@0
|
62 *
|
Chris@0
|
63 * Displays the last time we checked for locale update data. In addition to
|
Chris@0
|
64 * properly formatting the given timestamp, this function also provides a "Check
|
Chris@0
|
65 * manually" link that refreshes the available update and redirects back to the
|
Chris@0
|
66 * same page.
|
Chris@0
|
67 *
|
Chris@0
|
68 * Default template: locale-translation-last-check.html.twig.
|
Chris@0
|
69 *
|
Chris@0
|
70 * @param array $variables
|
Chris@0
|
71 * An associative array containing:
|
Chris@0
|
72 * - last: The timestamp when the site last checked for available updates.
|
Chris@0
|
73 *
|
Chris@0
|
74 * @see \Drupal\locale\Form\TranslationStatusForm
|
Chris@0
|
75 */
|
Chris@0
|
76 function template_preprocess_locale_translation_last_check(array &$variables) {
|
Chris@0
|
77 $last = $variables['last'];
|
Chris@0
|
78 $variables['last_checked'] = ($last != NULL);
|
Chris@0
|
79 $variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($last);
|
Chris@0
|
80 $variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', [], ['query' => \Drupal::destination()->getAsArray()]));
|
Chris@0
|
81 }
|