mirror of
https://github.com/deunix-educ/PyQuest.git
synced 2026-11-25 08:19:44 +01:00
Add UI components, i18n, settings store and base styles
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"app.title": "PyQuest",
|
||||
"engine.loading": "Loading Python… (the first time can take a few seconds)",
|
||||
"engine.failed": "Could not load Python. Reload the page or check your connection.",
|
||||
"step.progress": "Step {current} of {total}",
|
||||
"step.continue": "Continue",
|
||||
"voice.listen": "Listen",
|
||||
"voice.stop": "Stop reading",
|
||||
"cell.editor": "Python code editor",
|
||||
"cell.run": "Run",
|
||||
"cell.running": "Running…",
|
||||
"cell.stop": "Stop",
|
||||
"cell.reset": "Reset",
|
||||
"cell.hint": "Hint",
|
||||
"cell.hint_count": "Hint {current} of {total}",
|
||||
"cell.solution": "Show the solution",
|
||||
"cell.output": "Output",
|
||||
"cell.output_empty": "(nothing printed)",
|
||||
"cell.shortcut": "Ctrl/Cmd + Enter to run",
|
||||
"cell.passed": "Well done, that's correct!",
|
||||
"cell.failed": "Not yet. Here is what is wrong:",
|
||||
"cell.line": "Line {line}",
|
||||
"cell.details": "Technical details",
|
||||
"reason.syntax_error": "The code contains a syntax error.",
|
||||
"reason.stdout_mismatch": "What is printed is not exactly what is expected.",
|
||||
"reason.stdout_missing": "Something is missing from what is printed.",
|
||||
"reason.variable_missing": "An expected variable does not exist.",
|
||||
"reason.value_mismatch": "A variable does not have the right value.",
|
||||
"reason.type_mismatch": "A variable does not have the right type.",
|
||||
"reason.invalid_regex": "This test is badly defined (tell the level authors).",
|
||||
"reason.unsupported_kind": "This test is not handled by the app yet.",
|
||||
"reason.runtime_error": "The code stopped on an error.",
|
||||
"mission.label": "Mission",
|
||||
"mission.understand": "I understand",
|
||||
"mission.done": "Level complete! +{xp} XP",
|
||||
"mission.already": "Level already completed: no new XP, but well done for practising!",
|
||||
"progress.title": "Your progress",
|
||||
"progress.done": "Completed",
|
||||
"progress.current": "In progress",
|
||||
"progress.todo": "To do",
|
||||
"progress.xp": "{xp} XP",
|
||||
"progress.streak": "Streak: {days} day(s)",
|
||||
"badge.earned": "Badge earned: {name}",
|
||||
"badge.first_level": "First step",
|
||||
"badge.three_levels": "Three levels",
|
||||
"badge.xp_100": "100 XP",
|
||||
"badge.streak_3": "3 days in a row",
|
||||
"badge.streak_7": "7 days in a row",
|
||||
"toast.close": "Close",
|
||||
"settings.title": "Settings",
|
||||
"settings.language": "Language",
|
||||
"settings.fontSize": "Text size",
|
||||
"settings.theme": "Theme",
|
||||
"settings.theme.auto": "Automatic",
|
||||
"settings.theme.light": "Light",
|
||||
"settings.theme.dark": "Dark",
|
||||
"settings.sound": "Sound effects",
|
||||
"settings.volume": "Volume",
|
||||
"settings.voice": "Voice",
|
||||
"settings.voiceRate": "Voice speed"
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"app.title": "PyQuest",
|
||||
"engine.loading": "Chargement de Python… (la première fois peut prendre quelques secondes)",
|
||||
"engine.failed": "Impossible de charger Python. Recharge la page ou vérifie ta connexion.",
|
||||
"step.progress": "Étape {current} sur {total}",
|
||||
"step.continue": "Continuer",
|
||||
"voice.listen": "Écouter",
|
||||
"voice.stop": "Arrêter la lecture",
|
||||
"cell.editor": "Éditeur de code Python",
|
||||
"cell.run": "Exécuter",
|
||||
"cell.running": "Exécution en cours…",
|
||||
"cell.stop": "Arrêter",
|
||||
"cell.reset": "Réinitialiser",
|
||||
"cell.hint": "Indice",
|
||||
"cell.hint_count": "Indice {current} sur {total}",
|
||||
"cell.solution": "Voir la solution",
|
||||
"cell.output": "Résultat",
|
||||
"cell.output_empty": "(aucun affichage)",
|
||||
"cell.shortcut": "Ctrl/Cmd + Entrée pour exécuter",
|
||||
"cell.passed": "Bravo, c'est correct !",
|
||||
"cell.failed": "Pas encore. Voici ce qui ne va pas :",
|
||||
"cell.line": "Ligne {line}",
|
||||
"cell.details": "Détail technique",
|
||||
"reason.syntax_error": "Le code contient une erreur de syntaxe.",
|
||||
"reason.stdout_mismatch": "Ce qui s'affiche n'est pas exactement ce qui est attendu.",
|
||||
"reason.stdout_missing": "Il manque quelque chose dans ce qui s'affiche.",
|
||||
"reason.variable_missing": "Une variable attendue n'existe pas.",
|
||||
"reason.value_mismatch": "Une variable n'a pas la bonne valeur.",
|
||||
"reason.type_mismatch": "Une variable n'a pas le bon type.",
|
||||
"reason.invalid_regex": "Ce test est mal défini (signale-le aux auteurs du niveau).",
|
||||
"reason.unsupported_kind": "Ce test n'est pas encore géré par l'application.",
|
||||
"reason.runtime_error": "Le code s'est arrêté sur une erreur.",
|
||||
"mission.label": "Mission",
|
||||
"mission.understand": "Je comprends",
|
||||
"mission.done": "Niveau terminé ! +{xp} XP",
|
||||
"mission.already": "Niveau déjà terminé : pas de nouveaux XP, mais bien joué de t'être entraîné·e !",
|
||||
"progress.title": "Ta progression",
|
||||
"progress.done": "Terminé",
|
||||
"progress.current": "En cours",
|
||||
"progress.todo": "À faire",
|
||||
"progress.xp": "{xp} XP",
|
||||
"progress.streak": "Série : {days} jour(s)",
|
||||
"badge.earned": "Badge obtenu : {name}",
|
||||
"badge.first_level": "Premier pas",
|
||||
"badge.three_levels": "Trois niveaux",
|
||||
"badge.xp_100": "100 XP",
|
||||
"badge.streak_3": "3 jours de suite",
|
||||
"badge.streak_7": "7 jours de suite",
|
||||
"toast.close": "Fermer",
|
||||
"settings.title": "Réglages",
|
||||
"settings.language": "Langue",
|
||||
"settings.fontSize": "Taille du texte",
|
||||
"settings.theme": "Thème",
|
||||
"settings.theme.auto": "Automatique",
|
||||
"settings.theme.light": "Clair",
|
||||
"settings.theme.dark": "Sombre",
|
||||
"settings.sound": "Effets sonores",
|
||||
"settings.volume": "Volume",
|
||||
"settings.voice": "Voix",
|
||||
"settings.voiceRate": "Vitesse de la voix"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Traduction de l'interface : catalogues plats par langue, repli sur le français.
|
||||
|
||||
const FALLBACK_LANG = 'fr';
|
||||
|
||||
export class I18n extends EventTarget {
|
||||
#catalogs;
|
||||
#lang;
|
||||
|
||||
/** @param {Record<string, Record<string, string>>} catalogs Contenu de fr.json, en.json. */
|
||||
constructor(catalogs, lang = FALLBACK_LANG) {
|
||||
super();
|
||||
this.#catalogs = catalogs;
|
||||
this.#lang = catalogs[lang] ? lang : FALLBACK_LANG;
|
||||
}
|
||||
|
||||
get lang() {
|
||||
return this.#lang;
|
||||
}
|
||||
|
||||
get languages() {
|
||||
return Object.keys(this.#catalogs);
|
||||
}
|
||||
|
||||
setLang(lang) {
|
||||
if (this.#catalogs[lang] && lang !== this.#lang) {
|
||||
this.#lang = lang;
|
||||
this.dispatchEvent(new CustomEvent('change', { detail: { lang } }));
|
||||
}
|
||||
}
|
||||
|
||||
/** Traduit une clé ; les `{param}` sont remplacés. Une clé inconnue est renvoyée telle quelle. */
|
||||
t(key, params = {}) {
|
||||
const template = this.#catalogs[this.#lang]?.[key] ?? this.#catalogs[FALLBACK_LANG]?.[key] ?? key;
|
||||
return template.replace(/\{(\w+)\}/g, (whole, name) => String(params[name] ?? whole));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user