Skip to content
Snippets Groups Projects
Commit c0d6bbc7 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2565123 by joelpittet, lauriii: Move logic from SafeMarkup::format()...

Issue #2565123 by joelpittet, lauriii: Move logic from SafeMarkup::format() from template_preprocess_locale_translation_update_info() to template
parent 05ff65b5
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -123,6 +123,14 @@
font-size: 0.9em;
color: #666;
}
.locale-translation-update__details ul {
margin: 0;
padding: 0;
}
.locale-translation-update__details li {
margin: 0 0 0.25em 1.5em;
padding: 0;
}
@media screen and (max-width: 40em) {
#locale-translation-status-form th.title {
width: 20%;
......
......@@ -52,52 +52,19 @@ function locale_translation_manual_status() {
* @see \Drupal\locale\Form\TranslationStatusForm
*/
function template_preprocess_locale_translation_update_info(array &$variables) {
$details = array();
// Build output for available updates.
if (isset($variables['updates'])) {
$releases = array();
$variables['available_updates'] = [];
if ($variables['updates']) {
foreach ($variables['updates'] as $update) {
$modules[] = $update['name'];
$releases[] = SafeMarkup::format('@module (@date)', array(
'@module' => $update['name'],
'@date' => format_date($update['timestamp'], 'html_date'),
));
}
$variables['modules'] = $modules;
}
$details['available_updates_list'] = array(
'#theme' => 'item_list',
'#items' => $releases,
);
}
// Build output for updates not found.
if (isset($variables['not_found'])) {
$releases = array();
$variables['missing_updates_status'] = \Drupal::translation()->formatPlural(count($variables['not_found']), 'Missing translations for one project', 'Missing translations for @count projects');
if ($variables['not_found']) {
foreach ($variables['not_found'] as $update) {
$version = $update['version'] ? $update['version'] : t('no version');
$releases[] = SafeMarkup::format('@module (@version). @info', array(
'@module' => $update['name'],
'@version' => $version,
'@info' => $update['info'],
));
$variables['modules'][] = $update['name'];
// Format date for Twig template.
$release = $update;
$release['date'] = \Drupal::service('date.formatter')->format($update['timestamp'], 'html_date');
$variables['available_updates'][] = $release;
}
}
$details['missing_updates_list'] = array(
'#theme' => 'item_list',
'#items' => $releases,
);
// Prefix the missing updates list if there is an available updates lists
// before it.
if (!empty($details['available_updates_list']['#items'])) {
$details['missing_updates_list']['#prefix'] = t('Missing translations for:');
}
}
$variables['details'] = $details;
}
/**
......
......@@ -6,12 +6,9 @@
* Displays translation status information per language.
*
* Available variables:
* - modules: A list of names of modules that have available translation
* updates.
* - details: Rendered list of the translation details.
* - missing_updates_status: If there are any modules that are missing
* translation updates, this variable will contain text indicating how many
* modules are missing translations.
* - modules: A list of modules names that have available translation updates.
* - available_updates: A list of available translation updates.
* - not_found: A list of modules missing translation updates.
*
* @see template_preprocess_locale_translation_update_info()
*
......@@ -23,10 +20,40 @@
{% if modules %}
{% set module_list = modules|safe_join(', ') %}
<span class="locale-translation-update__message">{% trans %}Updates for: {{ module_list }}{% endtrans %}</span>
{% elseif missing_updates_status %}
<span class="locale-translation-update__message">{{ missing_updates_status }}</span>
{% elseif not_found %}
<span class="locale-translation-update__message">
{%- trans -%}
Missing translations for one project
{%- plural not_found|length -%}
Missing translations for @count projects
{%- endtrans -%}
</span>
{% endif %}
{% if details %}
<div class="locale-translation-update__details">{{ details }}</div>
{% if available_updates or not_found %}
<div class="locale-translation-update__details">
{% if available_updates %}
<ul>
{% for update in available_updates %}
<li>{{ update.name }} ({{ update.date }})</li>
{% endfor %}
</ul>
{% endif %}
{% if not_found %}
{#
Prefix the missing updates list if there is an available updates lists
before it.
#}
{% if available_updates %}
{{ 'Missing translations for:'|t }}
{% endif %}
{% if not_found %}
<ul class="item_list">
{% for update in not_found %}
<li>{{ update.name }} ({{ update.version|default('no version'|t) }}). {{ update.info }}</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
</div>
{% endif %}
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment