locale.pages.inc

Same filename and directory in other branches
  1. 8.9.x core/modules/locale/locale.pages.inc
  2. 10 core/modules/locale/locale.pages.inc
  3. 11.x core/modules/locale/locale.pages.inc

Interface translation summary, editing and deletion user interfaces.

File

core/modules/locale/locale.pages.inc

View source
<?php


/**
 * @file
 * Interface translation summary, editing and deletion user interfaces.
 */
use Drupal\Core\Link;
use Drupal\Core\Url;

/**
 * Prepares variables for translation status information templates.
 *
 * Translation status information is displayed per language.
 *
 * Default template: locale-translate-edit-form-strings.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - updates: The projects which have updates.
 *   - not_found: The projects which updates are not found.
 *
 * @see \Drupal\locale\Form\TranslationStatusForm
 */
function template_preprocess_locale_translation_update_info(array &$variables) {
    foreach ($variables['updates'] as $update) {
        $variables['modules'][] = $update['name'];
    }
}

/**
 * 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.
 *
 * @param array $variables
 *   An associative array containing:
 *   - last: The timestamp when the site last checked for available updates.
 *
 * @see \Drupal\locale\Form\TranslationStatusForm
 */
function template_preprocess_locale_translation_last_check(array &$variables) {
    $last = $variables['last'];
    $variables['last_checked'] = $last != NULL;
    $variables['time'] = $variables['last_checked'] ? \Drupal::service('date.formatter')->formatTimeDiffSince($last) : NULL;
    $variables['link'] = Link::fromTextAndUrl(t('Check manually'), Url::fromRoute('locale.check_translation', [], [
        'query' => \Drupal::destination()->getAsArray(),
    ]))
        ->toString();
}

Functions

Title Deprecated Summary
template_preprocess_locale_translation_last_check Prepares variables for most recent translation update templates.
template_preprocess_locale_translation_update_info Prepares variables for translation status information templates.

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