function LocaleThemeHooks::preprocessLocaleTranslationLastCheck

Prepares variables for most recent translation update templates.

Displays the last time we checked for locale update data. In addition to properly formatting the given timestamp, this function also provides a "Check manually" link that refreshes the available update and redirects back to the same page.

Default template: locale-translation-last-check.html.twig.

Parameters

array $variables: An associative array containing:

  • last: The timestamp when the site last checked for available updates.

See also

\Drupal\locale\Form\TranslationStatusForm

File

core/modules/locale/src/Hook/LocaleThemeHooks.php, line 85

Class

LocaleThemeHooks
Hook implementations for locale.

Namespace

Drupal\locale\Hook

Code

public function preprocessLocaleTranslationLastCheck(array &$variables) : void {
  $last = $variables['last'];
  $variables['last_checked'] = $last != NULL;
  $variables['time'] = $variables['last_checked'] ? $this->dateFormatter
    ->formatTimeDiffSince($last) : NULL;
  $variables['link'] = Link::fromTextAndUrl($this->t('Check manually'), Url::fromRoute('locale.check_translation', [], [
    'query' => $this->redirectDestination
      ->getAsArray(),
  ]))
    ->toString();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.