Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\locale\Controller;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Controller\ControllerBase;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Return response for manual check translations.
|
Chris@0
|
9 */
|
Chris@0
|
10 class LocaleController extends ControllerBase {
|
Chris@0
|
11
|
Chris@0
|
12 /**
|
Chris@0
|
13 * Checks for translation updates and displays the translations status.
|
Chris@0
|
14 *
|
Chris@0
|
15 * Manually checks the translation status without the use of cron.
|
Chris@0
|
16 *
|
Chris@0
|
17 * @return \Symfony\Component\HttpFoundation\RedirectResponse
|
Chris@0
|
18 * A redirection to translations reports page.
|
Chris@0
|
19 */
|
Chris@0
|
20 public function checkTranslation() {
|
Chris@0
|
21 $this->moduleHandler()->loadInclude('locale', 'inc', 'locale.compare');
|
Chris@0
|
22
|
Chris@0
|
23 // Check translation status of all translatable project in all languages.
|
Chris@0
|
24 // First we clear the cached list of projects. Although not strictly
|
Chris@0
|
25 // necessary, this is helpful in case the project list is out of sync.
|
Chris@0
|
26 locale_translation_flush_projects();
|
Chris@0
|
27 locale_translation_check_projects();
|
Chris@0
|
28
|
Chris@0
|
29 // Execute a batch if required. A batch is only used when remote files
|
Chris@0
|
30 // are checked.
|
Chris@0
|
31 if (batch_get()) {
|
Chris@0
|
32 return batch_process('admin/reports/translations');
|
Chris@0
|
33 }
|
Chris@0
|
34
|
Chris@0
|
35 return $this->redirect('locale.translate_status');
|
Chris@0
|
36 }
|
Chris@0
|
37
|
Chris@0
|
38 /**
|
Chris@0
|
39 * Shows the string search screen.
|
Chris@0
|
40 *
|
Chris@0
|
41 * @return array
|
Chris@0
|
42 * The render array for the string search screen.
|
Chris@0
|
43 */
|
Chris@0
|
44 public function translatePage() {
|
Chris@0
|
45 return [
|
Chris@0
|
46 'filter' => $this->formBuilder()->getForm('Drupal\locale\Form\TranslateFilterForm'),
|
Chris@0
|
47 'form' => $this->formBuilder()->getForm('Drupal\locale\Form\TranslateEditForm'),
|
Chris@0
|
48 ];
|
Chris@0
|
49 }
|
Chris@0
|
50
|
Chris@0
|
51 }
|