- Ajout onglet "Lexique" dans ConfluentTranslator - Recherche en temps réel à chaque lettre tapée - Sélecteur Proto/Ancien Confluent - Affichage français → confluent avec compteur - Endpoint /lexique dans server.js - Structure modulaire lexique-ancien/ (21 fichiers) - Format ultra-flexible : normalisation FR, multi-traductions, métadonnées - 20 domaines thématiques (castes, lieux, émotions, actions...) - ~500-600 mots à remplir (listés en commentaire _mots_a_gerer) - Structure modulaire lexique-proto/ (6 fichiers) - Racines monosyllabiques primitives - ~150-200 racines à remplir - README explicatif des différences Proto/Ancien Format JSON supporte : - Synonymes FR (chevaux → cheval) - Plusieurs traductions CF par mot FR - Compositions avec racines + sens littéral - Évolution Proto → Ancien 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
406 lines
12 KiB
HTML
406 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>ConfluentTranslator</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: #1a1a1a;
|
|
color: #e0e0e0;
|
|
padding: 20px;
|
|
line-height: 1.6;
|
|
}
|
|
.container { max-width: 900px; margin: 0 auto; }
|
|
h1 {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
color: #4a9eff;
|
|
font-size: 2em;
|
|
}
|
|
.panel {
|
|
background: #2a2a2a;
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
margin-bottom: 20px;
|
|
border: 1px solid #3a3a3a;
|
|
}
|
|
.panel h2 {
|
|
font-size: 1.2em;
|
|
margin-bottom: 15px;
|
|
color: #4a9eff;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 15px;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 5px;
|
|
color: #b0b0b0;
|
|
font-size: 0.9em;
|
|
}
|
|
select, input, textarea {
|
|
width: 100%;
|
|
padding: 10px;
|
|
background: #1a1a1a;
|
|
border: 1px solid #3a3a3a;
|
|
border-radius: 4px;
|
|
color: #e0e0e0;
|
|
font-family: inherit;
|
|
}
|
|
textarea {
|
|
resize: vertical;
|
|
min-height: 120px;
|
|
font-size: 0.95em;
|
|
}
|
|
button {
|
|
background: #4a9eff;
|
|
color: white;
|
|
border: none;
|
|
padding: 12px 24px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 1em;
|
|
font-weight: 600;
|
|
transition: background 0.2s;
|
|
}
|
|
button:hover { background: #357abd; }
|
|
button:disabled { background: #555; cursor: not-allowed; }
|
|
.output {
|
|
background: #1a1a1a;
|
|
padding: 15px;
|
|
border-radius: 4px;
|
|
border: 1px solid #3a3a3a;
|
|
min-height: 100px;
|
|
white-space: pre-wrap;
|
|
font-family: monospace;
|
|
color: #4a9eff;
|
|
}
|
|
.error { color: #ff4a4a; }
|
|
.row { display: flex; gap: 15px; }
|
|
.row .form-group { flex: 1; }
|
|
|
|
/* Tabs */
|
|
.tabs {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-bottom: 20px;
|
|
border-bottom: 2px solid #3a3a3a;
|
|
}
|
|
.tab {
|
|
background: transparent;
|
|
padding: 10px 20px;
|
|
border: none;
|
|
color: #b0b0b0;
|
|
cursor: pointer;
|
|
font-weight: 600;
|
|
border-bottom: 3px solid transparent;
|
|
transition: all 0.2s;
|
|
}
|
|
.tab:hover { color: #e0e0e0; }
|
|
.tab.active {
|
|
color: #4a9eff;
|
|
border-bottom-color: #4a9eff;
|
|
}
|
|
.tab-content { display: none; }
|
|
.tab-content.active { display: block; }
|
|
|
|
/* Lexique */
|
|
.lexique-results {
|
|
max-height: 400px;
|
|
overflow-y: auto;
|
|
margin-top: 15px;
|
|
}
|
|
.lexique-item {
|
|
background: #1a1a1a;
|
|
padding: 10px;
|
|
margin-bottom: 8px;
|
|
border-radius: 4px;
|
|
border-left: 3px solid #4a9eff;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
.lexique-fr {
|
|
color: #e0e0e0;
|
|
font-weight: 500;
|
|
}
|
|
.lexique-cf {
|
|
color: #4a9eff;
|
|
font-family: monospace;
|
|
font-size: 1.1em;
|
|
}
|
|
.lexique-count {
|
|
color: #b0b0b0;
|
|
font-size: 0.9em;
|
|
margin-top: 10px;
|
|
}
|
|
.no-results {
|
|
color: #b0b0b0;
|
|
text-align: center;
|
|
padding: 20px;
|
|
font-style: italic;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>ConfluentTranslator</h1>
|
|
|
|
<!-- Tabs -->
|
|
<div class="tabs">
|
|
<button class="tab active" data-tab="traduction">Traduction</button>
|
|
<button class="tab" data-tab="lexique">Lexique</button>
|
|
</div>
|
|
|
|
<!-- Tab: Traduction -->
|
|
<div id="tab-traduction" class="tab-content active">
|
|
<div class="panel">
|
|
<h2>Configuration</h2>
|
|
<div class="row">
|
|
<div class="form-group">
|
|
<label>Provider</label>
|
|
<select id="provider">
|
|
<option value="anthropic">Anthropic</option>
|
|
<option value="openai">OpenAI</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Modèle</label>
|
|
<select id="model">
|
|
<option value="claude-sonnet-4-5-20250929">Claude Sonnet 4.5</option>
|
|
<option value="claude-4-5-haiku-20250514">Claude Haiku 4.5</option>
|
|
<option value="gpt-4o-mini">GPT-4o Mini</option>
|
|
<option value="o1-mini">GPT o1-mini</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel">
|
|
<h2>Traduction</h2>
|
|
<div class="form-group">
|
|
<label>Langue cible</label>
|
|
<select id="target">
|
|
<option value="proto">Proto-Confluent</option>
|
|
<option value="ancien">Ancien Confluent</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Texte français</label>
|
|
<textarea id="input" placeholder="Entrez votre texte en français..."></textarea>
|
|
</div>
|
|
<button id="translate">Traduire</button>
|
|
</div>
|
|
|
|
<div class="panel">
|
|
<h2>Résultat</h2>
|
|
<div id="output" class="output">La traduction apparaîtra ici...</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tab: Lexique -->
|
|
<div id="tab-lexique" class="tab-content">
|
|
<div class="panel">
|
|
<h2>Recherche dans le lexique</h2>
|
|
<div class="form-group">
|
|
<label>Niveau de langue</label>
|
|
<select id="lexique-niveau">
|
|
<option value="proto">Proto-Confluent</option>
|
|
<option value="ancien">Ancien Confluent</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Rechercher un mot français</label>
|
|
<input type="text" id="lexique-search" placeholder="Tapez un mot en français...">
|
|
</div>
|
|
<div class="lexique-count" id="lexique-count">0 résultat(s)</div>
|
|
<div class="lexique-results" id="lexique-results">
|
|
<div class="no-results">Commencez à taper pour rechercher...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
// Lexique data
|
|
let lexiqueData = null;
|
|
|
|
// Load lexique
|
|
const loadLexique = async () => {
|
|
try {
|
|
const response = await fetch('/lexique');
|
|
lexiqueData = await response.json();
|
|
} catch (error) {
|
|
console.error('Error loading lexique:', error);
|
|
}
|
|
};
|
|
|
|
// Tab switching
|
|
document.querySelectorAll('.tab').forEach(tab => {
|
|
tab.addEventListener('click', () => {
|
|
// Remove active class from all tabs and contents
|
|
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
|
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
|
|
|
|
// Add active class to clicked tab and corresponding content
|
|
tab.classList.add('active');
|
|
const tabName = tab.dataset.tab;
|
|
document.getElementById(`tab-${tabName}`).classList.add('active');
|
|
});
|
|
});
|
|
|
|
// Lexique search
|
|
const searchLexique = () => {
|
|
const query = document.getElementById('lexique-search').value.toLowerCase().trim();
|
|
const niveau = document.getElementById('lexique-niveau').value;
|
|
const resultsDiv = document.getElementById('lexique-results');
|
|
const countDiv = document.getElementById('lexique-count');
|
|
|
|
if (!lexiqueData) {
|
|
resultsDiv.innerHTML = '<div class="no-results">Lexique en cours de chargement...</div>';
|
|
return;
|
|
}
|
|
|
|
if (!query) {
|
|
resultsDiv.innerHTML = '<div class="no-results">Commencez à taper pour rechercher...</div>';
|
|
countDiv.textContent = '0 résultat(s)';
|
|
return;
|
|
}
|
|
|
|
// For proto, we only have limited data (would need proto lexique file)
|
|
// For ancien, we use the full lexique
|
|
const dict = niveau === 'ancien' ? lexiqueData.dictionnaire : {};
|
|
|
|
// Search in all entries
|
|
const results = [];
|
|
for (const letter in dict) {
|
|
for (const [fr, cf] of Object.entries(dict[letter])) {
|
|
if (fr.toLowerCase().includes(query)) {
|
|
results.push({ fr, cf });
|
|
}
|
|
}
|
|
}
|
|
|
|
// Sort by relevance (starts with query first)
|
|
results.sort((a, b) => {
|
|
const aStarts = a.fr.toLowerCase().startsWith(query);
|
|
const bStarts = b.fr.toLowerCase().startsWith(query);
|
|
if (aStarts && !bStarts) return -1;
|
|
if (!aStarts && bStarts) return 1;
|
|
return a.fr.localeCompare(b.fr);
|
|
});
|
|
|
|
// Display results
|
|
if (results.length === 0) {
|
|
resultsDiv.innerHTML = '<div class="no-results">Aucun résultat trouvé</div>';
|
|
countDiv.textContent = '0 résultat(s)';
|
|
} else {
|
|
const html = results.map(r => `
|
|
<div class="lexique-item">
|
|
<span class="lexique-fr">${r.fr}</span>
|
|
<span class="lexique-cf">${r.cf}</span>
|
|
</div>
|
|
`).join('');
|
|
resultsDiv.innerHTML = html;
|
|
countDiv.textContent = `${results.length} résultat(s)`;
|
|
}
|
|
};
|
|
|
|
// Search on input
|
|
document.getElementById('lexique-search').addEventListener('input', searchLexique);
|
|
document.getElementById('lexique-niveau').addEventListener('change', searchLexique);
|
|
|
|
// Load config from localStorage
|
|
const loadConfig = () => {
|
|
const config = JSON.parse(localStorage.getItem('confluentConfig') || '{}');
|
|
if (config.provider) document.getElementById('provider').value = config.provider;
|
|
if (config.model) document.getElementById('model').value = config.model;
|
|
if (config.target) document.getElementById('target').value = config.target;
|
|
};
|
|
|
|
// Save config to localStorage
|
|
const saveConfig = () => {
|
|
const config = {
|
|
provider: document.getElementById('provider').value,
|
|
model: document.getElementById('model').value,
|
|
target: document.getElementById('target').value,
|
|
};
|
|
localStorage.setItem('confluentConfig', JSON.stringify(config));
|
|
};
|
|
|
|
// Update model options based on provider
|
|
document.getElementById('provider').addEventListener('change', (e) => {
|
|
const modelSelect = document.getElementById('model');
|
|
modelSelect.innerHTML = '';
|
|
|
|
if (e.target.value === 'anthropic') {
|
|
modelSelect.innerHTML = `
|
|
<option value="claude-sonnet-4-5-20250929">Claude Sonnet 4.5</option>
|
|
<option value="claude-4-5-haiku-20250514">Claude Haiku 4.5</option>
|
|
`;
|
|
} else if (e.target.value === 'openai') {
|
|
modelSelect.innerHTML = `
|
|
<option value="gpt-4o-mini">GPT-4o Mini</option>
|
|
<option value="o1-mini">GPT o1-mini</option>
|
|
`;
|
|
}
|
|
saveConfig();
|
|
});
|
|
|
|
// Save config on change
|
|
document.getElementById('model').addEventListener('change', saveConfig);
|
|
document.getElementById('target').addEventListener('change', saveConfig);
|
|
|
|
// Translation
|
|
document.getElementById('translate').addEventListener('click', async () => {
|
|
const button = document.getElementById('translate');
|
|
const output = document.getElementById('output');
|
|
const text = document.getElementById('input').value.trim();
|
|
|
|
if (!text) {
|
|
output.innerHTML = '<span class="error">Veuillez entrer un texte.</span>';
|
|
return;
|
|
}
|
|
|
|
button.disabled = true;
|
|
output.textContent = 'Traduction en cours...';
|
|
|
|
const config = {
|
|
text,
|
|
target: document.getElementById('target').value,
|
|
provider: document.getElementById('provider').value,
|
|
model: document.getElementById('model').value,
|
|
};
|
|
|
|
try {
|
|
const response = await fetch('/translate', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(config),
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
output.textContent = data.translation;
|
|
} else {
|
|
output.innerHTML = `<span class="error">Erreur: ${data.error}</span>`;
|
|
}
|
|
} catch (error) {
|
|
output.innerHTML = `<span class="error">Erreur: ${error.message}</span>`;
|
|
} finally {
|
|
button.disabled = false;
|
|
}
|
|
});
|
|
|
|
// Initialize
|
|
loadConfig();
|
|
loadLexique();
|
|
</script>
|
|
</body>
|
|
</html>
|