Skip to content

Update logo, add translations and fix comments : Traduction FR/EN, toggle de langue, refonte des commentaires et corrections - #49

Merged
raynaldlao merged 16 commits into
masterfrom
update-logo-translation-and-fix-comments
Jul 24, 2026
Merged

Update logo, add translations and fix comments : Traduction FR/EN, toggle de langue, refonte des commentaires et corrections#49
raynaldlao merged 16 commits into
masterfrom
update-logo-translation-and-fix-comments

Conversation

@raynaldlao

@raynaldlao raynaldlao commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Contexte

Traduction complète du blog (FR/EN), ajout d'un sélecteur de langue, refonte du système de commentaires (edit, soft-delete, cascade hard-delete) et correctifs divers.


🌍 Internationalisation (i18n)

  • Flask-Babel intégré : gettext() côté serveur, _t() côté client
  • Fichiers de traduction : translations/fr/LC_MESSAGES/messages.po/.mo + messages.pot
  • Tous les templates passent par _() : flash messages, rôles, dates, erreurs 403/404/500
  • BlockNote et SunEditor en français (pack fr.js)
  • Dates localisées via format_datetime_locale("d MMMM yyyy")
  • Tests : test_template_helpers.py, test_lang_integration.py, frontend i18n.test.js

🔤 Sélecteur de langue

  • Bouton FR/EN dans la navbar (même style que le theme toggle)
  • Route POST /lang/<locale> avec CSRF
  • Locale stockée en session, lue par locale_selector Babel
  • 3 tests : fr / en / locale invalide

💬 Refonte des commentaires

  • Reply/Edit unifiés : formulaire unique, toggle au clic, bouton Cancel
  • Soft-delete : is_deleted=True, contenu préservé, arbre conservé
  • Edit : auteur uniquement, textarea inline, horodatage edited_at
  • Hard-delete cascade (migration V16) : FK ON DELETE CASCADE — supprimer un parent supprime tous les descendants
  • Texte [deleted] + "Comment removed" traduit

🎨 CSS & UI

  • Favicon remplacé par logo DJ (#7C3AED, JetBrains Mono)
  • Pagination : .input-error dans user-list.css
  • overflow-wrap: break-word sur .user-card h1
  • display: contents pour l'avatar (profile.css)
  • overflow-x: hidden à 360px pour le formulaire SunEditor

🐛 Corrections

  • Copy code-block : execCommand('copy') + fallback toast "Failed to copy"
  • Double-tap mobile : handlers split desktop/mobile, reset sur blur
  • Anonymous author : basé sur *_id is None plutôt que chaîne anglaise
  • console.log retirés de suneditor-init.js
  • Tests Vitest : document.execCommand mocké avec ClipboardEvent + DataTransfer (Happy DOM natif), 3 tests alignés sur le comportement réel — 123 tests verts

⚙️ Dev ergonomics

  • Auto-restart Flask sur pybabel compile : extra_files surveille les .mo — plus besoin de kill manuel

…with a DJ‑style logo. The old SVG is removed and replaced by a JetBrains Mono “DJ” glyph on a #7C3AED background, giving the site a clean high‑contrast square icon
…ed: BlockNote runs in `fr`, backend errors use `gettext()`, and all frontend strings go through `_()`. Dates are fully locale‑aware via `format_datetime_locale`, replacing old English DTO formats. French `.po/.mo` files are stored under `translations/fr LC_MESSAGES/`, with tests for `_()`, the file adapter, and localized datetime formatting, plus final template/styletouch‑ups
… role labels now use `_(user.account_role)` with new `admin/author/user` entries, templates use `format_datetime_locale("d MMMM yyyy")` for locale‑aware dates, the missing self‑delete translation is fixed, the old `date_format_filter` is removed and the article list test expects "29 April 2026"
…with full coverage of remaining English toasts and code‑block UI strings. Code‑block labels now use `_()`, comment‑reply reads all texts from Jinja datasets, copy and editor scripts use `_t()`, ArticleForm wraps its upload error, seven missing keys are added to template JSON blocks and compiled, profile CSS gains `display:contents`, and profile‑avatar keeps its French hardcoded errors
…r SunEditor toolbar and emoji picker. The French lang pack `fr.js` is included and loaded before the editor init. `suneditor-init.js` adapts flat keys to nested ones, sets the `lang` option and wraps the emoji tooltip with `_t('Insert Emoji')`. The emoji picker now shows French categories, search text, and skin labels. `article_detail.html` includes the `Insert Emoji` key in its JSON block and the translation is added and compiled in `messages.po/.mo`
…or-init.js` with helper encapsulation, double‑tap fix and removal of debug logs. `_t` and `resolveLang` are moved into an IIFE to avoid globals, the double‑tap logic is split between desktop and mobile to prevent the line‑jump caused by corrupted selection, both tap timers reset on blur, indentation in the mapping loop is corrected and all `console.log` calls are removed
…r “Comment removed” and “Anonymous”. Display logic moves from the DTO to templates using `_()`. Checks for anonymous authors now rely on `*_id is none` instead of comparing the English string and templates render `{{ _('Anonymous') }}`. Tests are updated accordingly and translation files (`.po/.mo/.pot`) rebuilt
…BlockNote paste are fixed. Copy now uses a custom `copy` event with `execCommand('copy')`, letting BlockNote read `text/html`. The clipboard HTML includes a `<blocknote-block>` wrapper, trailing `<br>` is replaced with a zero‑width space, empty blocks still trigger the toast, a `!pre` guard protects `cloneNode`, copy failures show a translated “Failed to copy” and all debug code is removed
…atar updated. The hardcoded `A` initial is replaced with `?`, avoiding confusion with real user initials and matching the soft‑deleted comment avatar style. Change applied in `article_detail.html` at line 105
…d for remaining English strings. The 403/404/500 error messages are now wrapped in `_()` and translated. Role labels (`admin`/`author`/`user`) are restored from obsolete entries so `{{ _(role) }}` resolves correctly. “Please sign in to join the conversation” receives its missing French msgstr. Obsolete blocks are removed, six new msgids added to the `.pot`, and `.mo` recompiled
…g added to the user‑list jump input. `#jump-page-input.input-error` now gets the same red border and focus box‑shadow as the stepper controls, so an empty or invalid “Go” action shows a consistent error state in the user‑manager modal. Rules added directly in `user-list.css`
…he single main comment form with a simple toggle. All inline per‑comment forms are removed; clicking Reply or Edit activates the shared form and clicking again cancels it. Button text switches to “Cancel” / “Annuler”. Old CSS/JS tied to inline edit blocks is deleted, and `overflow-x: hidden` prevents the SunEditor toolbar from causing horizontal scroll at 360 px
…d, locale now stored in session and updated via POST `/lang/<locale>`, navbar gets a FR/EN switch styled like the theme toggle, session adapter gains `set_lang`, tests cover fr/en/invalid; translation templates updated
…done, the meta description in `article_list.html` and the lang‑toggle title in `base.html` are now wrapped in `_()` for proper i18n, the navbar language switch uses the translated “Switch language”, `user-list.css` gets `overflow-wrap: break-word` on `.user-card h1` with reduced padding at 30em to fix mobile overflow, new msgids extracted, updated, compiled
…fixed, parent removal now cascades to children instead of orphaning them. Migration V16 switches FK from ON DELETE SET NULL to ON DELETE CASCADE, the SQLAlchemy model sets `ondelete="CASCADE"` with an updated docstring, the service docstring reflects true hard‑delete semantics and integration tests validate the cascade on a full tree (P → A,B → C plus an unrelated branch)
@raynaldlao
raynaldlao requested a review from hlargitte July 23, 2026 19:23
@raynaldlao raynaldlao self-assigned this Jul 23, 2026
…ved, Flask now auto‑reloads when `.mo` files are compiled thanks to `extra_files` watching the glob, vitest’s `execCommand` mock is fixed to dispatch a real `ClipboardEvent` with a `DataTransfer` object matching actual `code-copy.js` behavior, three tests updated accordingly

@hlargitte hlargitte left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@raynaldlao
raynaldlao merged commit 3dbc201 into master Jul 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants