summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/locale/src/Controller/LocaleController.php
blob: 2617c61cffecfb6bfcc73be20838d07d7fea8818 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

namespace Drupal\locale\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
 * Return response for manual check translations.
 */
class LocaleController extends ControllerBase {

  /**
   * Checks for translation updates and displays the translations status.
   *
   * Manually checks the translation status without the use of cron.
   *
   * @return \Symfony\Component\HttpFoundation\RedirectResponse
   *   A redirection to translations reports page.
   */
  public function checkTranslation() {
    $this->moduleHandler()->loadInclude('locale', 'inc', 'locale.compare');

    // Check translation status of all translatable project in all languages.
    // First we clear the cached list of projects. Although not strictly
    // necessary, this is helpful in case the project list is out of sync.
    locale_translation_flush_projects();
    locale_translation_check_projects();

    // Execute a batch if required. A batch is only used when remote files
    // are checked.
    if (batch_get()) {
      return batch_process('admin/reports/translations');
    }

    return $this->redirect('locale.translate_status');
  }

  /**
   * Shows the string search screen.
   *
   * @return array
   *   The render array for the string search screen.
   */
  public function translatePage() {
    return [
      'filter' => $this->formBuilder()->getForm('Drupal\locale\Form\TranslateFilterForm'),
      'form' => $this->formBuilder()->getForm('Drupal\locale\Form\TranslateEditForm'),
    ];
  }

}