up autotraduction de toutes les pages manquantes en français listées
This commit is contained in:
parent
eb662fab5a
commit
920cf3af33
34 changed files with 26563 additions and 13 deletions
|
@ -191,11 +191,74 @@
|
|||
title="Créer une traduction française">
|
||||
<i class="bi bi-plus-circle"></i> Traduire
|
||||
</a>
|
||||
{# <a href="{{ path('app_admin_wiki_compare', {'key': key}) }}" #}
|
||||
{# class="btn btn-sm btn-outline-secondary" #}
|
||||
{# title="Voir les détails et comparer"> #}
|
||||
{# <i class="bi bi-arrows-angle-expand"></i> Comparer #}
|
||||
{# </a> #}
|
||||
{% if available_translations[key] is defined %}
|
||||
<a href="{{ path('app_admin_wiki_update_translation', {'key': key}) }}"
|
||||
class="btn btn-sm btn-warning"
|
||||
title="Mettre à jour la traduction automatique">
|
||||
<i class="bi bi-arrow-clockwise"></i> Mettre à jour
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ path('app_admin_wiki_translate', {'key': key}) }}"
|
||||
class="btn btn-sm btn-primary"
|
||||
title="Traduire automatiquement avec Ollama">
|
||||
<i class="bi bi-robot"></i> Auto traduire
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if available_translations is defined and available_translations|length > 0 %}
|
||||
<div class="card mb-4">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h2>Traductions automatiques disponibles ({{ available_translations|length }})</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Ces pages ont été traduites automatiquement par le modèle Mistral:7b via Ollama. Vous pouvez copier le contenu pour créer une page wiki.</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Clé</th>
|
||||
<th>Date de traduction</th>
|
||||
<th>Modèle</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for key, translation in available_translations %}
|
||||
<tr>
|
||||
<td><strong>{{ key }}</strong></td>
|
||||
<td>{{ translation.translated_at|date('Y-m-d H:i:s') }}</td>
|
||||
<td>{{ translation.model }}</td>
|
||||
<td class="text-center">
|
||||
<div class="btn-group" role="group">
|
||||
<a href="{{ translation.en_page.url }}" target="_blank"
|
||||
class="btn btn-sm btn-outline-info" title="Version anglaise">
|
||||
<i class="bi bi-flag-fill"></i> EN
|
||||
</a>
|
||||
<button class="btn btn-sm btn-success copy-translation"
|
||||
data-translation="{{ translation.translated_content|e('html_attr') }}"
|
||||
title="Copier la traduction">
|
||||
<i class="bi bi-clipboard"></i> Copier
|
||||
</button>
|
||||
<a href="{{ path('app_admin_wiki_update_translation', {'key': key}) }}"
|
||||
class="btn btn-sm btn-warning"
|
||||
title="Mettre à jour la traduction">
|
||||
<i class="bi bi-arrow-clockwise"></i> Mettre à jour
|
||||
</a>
|
||||
<a href="{{ path('app_admin_wiki_create_french', {'key': key}) }}"
|
||||
class="btn btn-sm btn-primary"
|
||||
title="Créer une page wiki avec cette traduction">
|
||||
<i class="bi bi-plus-circle"></i> Créer page
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -462,7 +525,43 @@
|
|||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Collect data from the table
|
||||
// Handle copy translation buttons
|
||||
const copyButtons = document.querySelectorAll('.copy-translation');
|
||||
copyButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const translation = this.getAttribute('data-translation');
|
||||
|
||||
// Create a temporary textarea element to copy from
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = translation;
|
||||
textarea.setAttribute('readonly', '');
|
||||
textarea.style.position = 'absolute';
|
||||
textarea.style.left = '-9999px';
|
||||
document.body.appendChild(textarea);
|
||||
|
||||
// Select and copy the text
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
|
||||
// Remove the textarea
|
||||
document.body.removeChild(textarea);
|
||||
|
||||
// Change button text temporarily to indicate success
|
||||
const originalText = this.innerHTML;
|
||||
this.innerHTML = '<i class="bi bi-check"></i> Copié!';
|
||||
this.classList.remove('btn-success');
|
||||
this.classList.add('btn-outline-success');
|
||||
|
||||
// Restore original button text after a delay
|
||||
setTimeout(() => {
|
||||
this.innerHTML = originalText;
|
||||
this.classList.remove('btn-outline-success');
|
||||
this.classList.add('btn-success');
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
|
||||
// Collect data for the chart
|
||||
const labels = [];
|
||||
const scores = [];
|
||||
const colors = [];
|
||||
|
|
|
@ -796,6 +796,59 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% if history_data is defined and history_data|length > 0 %}
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h2>Historique des mesures</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Ce graphique montre l'évolution du score de décrépitude et des métriques associées au fil du temps :</p>
|
||||
|
||||
<div class="mb-4">
|
||||
<canvas id="historyChart" width="400" height="200"></canvas>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Score de décrépitude</th>
|
||||
<th>Diff. de date (jours)</th>
|
||||
<th>Diff. de mots</th>
|
||||
<th>Diff. de sections</th>
|
||||
<th>Diff. de liens</th>
|
||||
<th>Diff. d'images</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entry in history_data %}
|
||||
<tr>
|
||||
<td>{{ entry.date }}</td>
|
||||
<td>{{ entry.metrics.staleness_score|round(2) }}</td>
|
||||
<td>{{ entry.metrics.date_diff }}</td>
|
||||
<td>{{ entry.metrics.word_diff }}</td>
|
||||
<td>{{ entry.metrics.section_diff }}</td>
|
||||
<td>{{ entry.metrics.link_diff }}</td>
|
||||
<td>{{ entry.metrics.media_diff }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info mt-3">
|
||||
<p><strong>À propos de l'historique :</strong></p>
|
||||
<ul>
|
||||
<li>L'historique montre l'évolution des métriques au fil du temps, permettant de suivre les progrès ou la dégradation de la traduction.</li>
|
||||
<li>Une tendance à la baisse du score de décrépitude indique une amélioration de la qualité de la traduction.</li>
|
||||
<li>Les données sont collectées à chaque exécution du script d'analyse.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="mt-3">
|
||||
<a href="{{ path('app_admin_wiki') }}" class="btn btn-secondary">
|
||||
<i class="bi bi-arrow-left"></i> Retour à la liste des pages wiki
|
||||
|
@ -932,6 +985,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% block javascripts %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.7.1/dist/chart.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Add click event listeners to all copy buttons
|
||||
|
@ -1023,6 +1077,123 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Create history chart if the element exists
|
||||
const historyChartElement = document.getElementById('historyChart');
|
||||
if (historyChartElement) {
|
||||
// Get history data from the template
|
||||
const historyData = {{ history_data|json_encode|raw }};
|
||||
|
||||
if (historyData && historyData.length > 0) {
|
||||
// Prepare data for the chart
|
||||
const labels = historyData.map(entry => entry.date);
|
||||
const stalenessScores = historyData.map(entry => entry.metrics.staleness_score);
|
||||
const wordDiffs = historyData.map(entry => entry.metrics.word_diff);
|
||||
const sectionDiffs = historyData.map(entry => entry.metrics.section_diff);
|
||||
const linkDiffs = historyData.map(entry => entry.metrics.link_diff);
|
||||
|
||||
// Create the chart
|
||||
const ctx = historyChartElement.getContext('2d');
|
||||
const historyChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Score de décrépitude',
|
||||
data: stalenessScores,
|
||||
borderColor: 'rgba(255, 99, 132, 1)',
|
||||
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
||||
borderWidth: 2,
|
||||
tension: 0.1,
|
||||
yAxisID: 'y'
|
||||
},
|
||||
{
|
||||
label: 'Différence de mots',
|
||||
data: wordDiffs,
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||
borderWidth: 2,
|
||||
tension: 0.1,
|
||||
yAxisID: 'y1',
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
label: 'Différence de sections',
|
||||
data: sectionDiffs,
|
||||
borderColor: 'rgba(75, 192, 192, 1)',
|
||||
backgroundColor: 'rgba(75, 192, 192, 0.2)',
|
||||
borderWidth: 2,
|
||||
tension: 0.1,
|
||||
yAxisID: 'y1',
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
label: 'Différence de liens',
|
||||
data: linkDiffs,
|
||||
borderColor: 'rgba(153, 102, 255, 1)',
|
||||
backgroundColor: 'rgba(153, 102, 255, 0.2)',
|
||||
borderWidth: 2,
|
||||
tension: 0.1,
|
||||
yAxisID: 'y1',
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
interaction: {
|
||||
mode: 'index',
|
||||
intersect: false,
|
||||
},
|
||||
stacked: false,
|
||||
scales: {
|
||||
y: {
|
||||
type: 'linear',
|
||||
display: true,
|
||||
position: 'left',
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Score de décrépitude'
|
||||
}
|
||||
},
|
||||
y1: {
|
||||
type: 'linear',
|
||||
display: true,
|
||||
position: 'right',
|
||||
grid: {
|
||||
drawOnChartArea: false,
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Différences'
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Évolution des métriques au fil du temps'
|
||||
},
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
label: function(context) {
|
||||
let label = context.dataset.label || '';
|
||||
if (label) {
|
||||
label += ': ';
|
||||
}
|
||||
if (context.parsed.y !== null) {
|
||||
label += context.parsed.y.toFixed(2);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue