chore: remove helper
This commit is contained in:
@@ -1,118 +0,0 @@
|
||||
"""Fix Files + Advanced Editing help sections."""
|
||||
import json
|
||||
|
||||
with open('frontend/index.html', 'r', encoding='utf-8') as f: html = f.read()
|
||||
with open('frontend/locales/fr.json', 'r', encoding='utf-8') as f: fr = json.load(f)
|
||||
with open('frontend/locales/en.json', 'r', encoding='utf-8') as f: en = json.load(f)
|
||||
|
||||
fixes = [
|
||||
# FILES section
|
||||
('<p>Les fichiers markdown sont rendus avec :</p>',
|
||||
'help.desc_md_render', 'Markdown files are rendered with:', 'p'),
|
||||
|
||||
('<strong>Wikilinks cliquables</strong> :\n <code>[[lien]]</code> et\n <code>[[lien|texte]]</code>',
|
||||
'help.desc_wikilinks', ': <code>[[link]]</code> and <code>[[link|text]]</code>', 'strong'),
|
||||
|
||||
('<strong>Images Obsidian</strong> : Support\n de <code>![[image.png]]</code>',
|
||||
'help.desc_images', ': Supports <code>![[image.png]]</code>', 'strong'),
|
||||
|
||||
('<strong>Syntax highlighting</strong> :\n Coloration des blocs de code',
|
||||
'help.desc_syntax_hl', ': Code block highlighting', 'strong'),
|
||||
|
||||
('<strong>Tables, listes, quotes</strong> :\n Rendu complet du markdown',
|
||||
'help.desc_markdown_all', ': Full markdown rendering', 'strong'),
|
||||
|
||||
# File actions
|
||||
('Copier</strong> : Copie le contenu\n source dans le presse-papiers',
|
||||
'help.desc_copy_btn', ': Copies source content to clipboard', 'strong'),
|
||||
|
||||
('Source</strong> : Affiche/masque le\n markdown brut',
|
||||
'help.desc_source_btn', ': Shows/hides raw markdown', 'strong'),
|
||||
|
||||
('<strong\n >Ouvrir dans nouvelle fenêtre</strong\n >\n : Ouvre le fichier dans un nouvel onglet',
|
||||
'help.desc_open_new', ': Opens the file in a new tab', 'strong'),
|
||||
|
||||
# CodeMirror features
|
||||
('<strong>Coloration syntaxique</strong> :\n Support de nombreux langages',
|
||||
'help.desc_cm_syntax', ': Supports many languages', 'strong'),
|
||||
|
||||
('Numéros de ligne</strong> :\n Navigation facile',
|
||||
'help.desc_cm_lines', ': Easy navigation', 'strong'),
|
||||
|
||||
('Autocomplétion</strong> :\n Suggestions contextuelles',
|
||||
'help.desc_cm_autocomplete', ': Contextual suggestions', 'strong'),
|
||||
|
||||
('Recherche</strong> : Ctrl+F pour\n chercher dans le fichier',
|
||||
'help.desc_cm_search', ': Ctrl+F to search in the file', 'strong'),
|
||||
|
||||
('<strong>Sauvegarde</strong> : Bouton ✓ pour\n enregistrer',
|
||||
'help.desc_save_btn', ': ✓ button to save', 'strong'),
|
||||
|
||||
('<strong>Suppression</strong> : Bouton\n corbeille pour supprimer',
|
||||
'help.desc_delete_btn', ': Trash button to delete', 'strong'),
|
||||
|
||||
# ADVANCED EDITING section
|
||||
# h2 title
|
||||
('<h2 data-i18n=\"auto.f346076a\">✏️ Édition avancée</h2>',
|
||||
'help.adv_editing', '✏️ Advanced Editing', 'h2_direct'),
|
||||
|
||||
('<h3 data-i18n=\"auto.695d9e47\">Éditeur CodeMirror 6</h3>',
|
||||
'help.cm6_title', 'CodeMirror 6 Editor', 'h3_direct'),
|
||||
|
||||
# Editing features
|
||||
('<strong>Coloration syntaxique</strong> :\n Python, JS, HTML, CSS, Java, C++, Rust, Go\n et bien d\'autres',
|
||||
'help.desc_adv_syntax', ': Python, JS, HTML, CSS, Java, C++, Rust, Go and many more', 'strong'),
|
||||
|
||||
('<strong>Find in page</strong> : Ctrl+F pour\n chercher dans le fichier (casse, regex, mot\n entier)',
|
||||
'help.desc_find_in_page', ': Ctrl+F to search in the file (case, regex, whole word)', 'strong'),
|
||||
|
||||
('<strong>Bouton ✓</strong> : Sauvegarde\n manuelle',
|
||||
'help.desc_check_btn', ': Manual save', 'strong'),
|
||||
|
||||
('<strong>Bouton 🗑️</strong> : Suppression du\n fichier',
|
||||
'help.desc_trash_btn', ': Delete file', 'strong'),
|
||||
]
|
||||
|
||||
count = 0
|
||||
for old_snippet, key, en_val, mode in fixes:
|
||||
if old_snippet in html:
|
||||
if mode == 'p':
|
||||
new_snippet = old_snippet.replace('<p>', f'<p data-i18n="{key}">')
|
||||
fr_val = old_snippet.replace('<p>','').replace('</p>','').strip()
|
||||
elif mode == 'strong':
|
||||
parts = old_snippet.split('</strong>')
|
||||
fr_val = parts[1].strip()
|
||||
new_snippet = parts[0] + '</strong><span data-i18n="' + key + '">' + fr_val + '</span>'
|
||||
elif mode == 'h2_direct':
|
||||
new_snippet = f'<h2 data-i18n="{key}">✏️ Advanced Editing</h2>'
|
||||
fr_val = '✏️ Édition avancée'
|
||||
elif mode == 'h3_direct':
|
||||
new_snippet = f'<h3 data-i18n="{key}">CodeMirror 6 Editor</h3>'
|
||||
fr_val = 'Éditeur CodeMirror 6'
|
||||
else:
|
||||
continue
|
||||
|
||||
html = html.replace(old_snippet, new_snippet)
|
||||
fr[key] = fr_val
|
||||
en[key] = en_val
|
||||
count += 1
|
||||
else:
|
||||
print(f"NOT FOUND: {old_snippet[:60]}...")
|
||||
|
||||
# Fix EN for existing spans in editing
|
||||
en_fixes = {
|
||||
'help.desc_065f53ee': ': Silent auto-save after 2s of inactivity, green confirmation flash',
|
||||
'help.desc_c8532869': ': Completion, rewrite, translation (see',
|
||||
'help.desc_a52fc3b1': ': Downloads the file',
|
||||
'help.desc_995a711f': ': Opens the CodeMirror editor',
|
||||
}
|
||||
for k, v in en_fixes.items():
|
||||
if k not in fr:
|
||||
fr[k] = v
|
||||
en[k] = v
|
||||
count += 1
|
||||
|
||||
with open('frontend/index.html', 'w', encoding='utf-8') as f: f.write(html)
|
||||
with open('frontend/locales/fr.json', 'w', encoding='utf-8') as f: json.dump(fr, f, ensure_ascii=False, indent=2)
|
||||
with open('frontend/locales/en.json', 'w', encoding='utf-8') as f: json.dump(en, f, ensure_ascii=False, indent=2)
|
||||
print(f'Fixed: {count}')
|
||||
Reference in New Issue
Block a user