feat: localize YouTube "view all videos" button#173
Conversation
Agent-Logs-Url: https://github.com/DavidKRK/DavidKRK.github.io/sessions/dcf70b48-1135-44bd-ac4e-03d97467e100 Co-authored-by: DavidKRK <136035295+DavidKRK@users.noreply.github.com>
|
|
There was a problem hiding this comment.
Code Review
This pull request implements localization for the YouTube section in music.html by adding translation strings and manual DOM update logic. The review feedback suggests adopting the project's existing declarative localization pattern using the .lang-content class and data-lang attributes. This approach would eliminate the need for the manual JavaScript translation object and DOM manipulation, ensuring consistency with the rest of the codebase and simplifying maintenance.
| <!-- YOUTUBE-AUTO-START --> | ||
| <section class="youtube-section"> | ||
| <h3><i class="fab fa-youtube" style="color:#ff0000;"></i> Dernières vidéos YouTube</h3> | ||
| <h3><i class="fab fa-youtube" style="color:#ff0000;"></i> <span id="youtube-section-title">Dernières vidéos YouTube</span></h3> |
There was a problem hiding this comment.
The project already uses a declarative pattern for localization (see lines 123-128) using the .lang-content class and data-lang attribute. To maintain consistency and reduce redundant JavaScript logic, it is recommended to use the same pattern here. This also allows you to correctly set the dir="rtl" attribute for the Arabic translation directly in the HTML.
<h3><i class="fab fa-youtube" style="color:#ff0000;"></i>
<span class="lang-content" data-lang="fr">Dernières vidéos YouTube</span>
<span class="lang-content" data-lang="en">Latest YouTube Videos</span>
<span class="lang-content" data-lang="es">Últimos vídeos de YouTube</span>
<span class="lang-content" data-lang="eu">Azken YouTube bideoak</span>
<span class="lang-content" data-lang="ar" dir="rtl">أحدث مقاطع فيديو يوتيوب</span>
<span class="lang-content" data-lang="uk">Останні відео YouTube</span>
</h3>| <a href="https://www.youtube.com/@DavidKRKofficial" target="_blank" rel="noopener noreferrer" | ||
| style="display:inline-flex;align-items:center;gap:0.5rem;background:#ff0000;color:#fff;padding:0.6rem 1.4rem;border-radius:6px;font-family:'Russo One',sans-serif;font-size:0.9rem;text-decoration:none;transition:background 0.2s;"> | ||
| <i class="fab fa-youtube"></i> Voir toutes les vidéos | ||
| <i class="fab fa-youtube"></i> <span id="youtube-btn-text">Voir toutes les vidéos</span> |
There was a problem hiding this comment.
Similar to the section title, using the declarative pattern for the button text ensures consistency and leverages the existing language switching logic. Note that you may need to ensure your CSS for .lang-content uses display: inline or display: contents when active to avoid breaking the button's layout.
<i class="fab fa-youtube"></i>
<span class="lang-content" data-lang="fr">Voir toutes les vidéos</span>
<span class="lang-content" data-lang="en">View all videos</span>
<span class="lang-content" data-lang="es">Ver todos los vídeos</span>
<span class="lang-content" data-lang="eu">Ikusi bideo guztiak</span>
<span class="lang-content" data-lang="ar" dir="rtl">عرض جميع مقاطع الفيديو</span>
<span class="lang-content" data-lang="uk">Переглянути всі відео</span>| const langContent = { | ||
| fr: { youtube_title: 'Dernières vidéos YouTube', youtube_button: 'Voir toutes les vidéos' }, | ||
| en: { youtube_title: 'Latest YouTube Videos', youtube_button: 'View all videos' }, | ||
| es: { youtube_title: 'Últimos vídeos de YouTube', youtube_button: 'Ver todos los vídeos' }, | ||
| eu: { youtube_title: 'Azken YouTube bideoak', youtube_button: 'Ikusi bideo guztiak' }, | ||
| ar: { youtube_title: 'أحدث مقاطع فيديو يوتيوب', youtube_button: 'عرض جميع مقاطع الفيديو' }, | ||
| uk: { youtube_title: 'Останні відео YouTube', youtube_button: 'Переглянути всі відео' } | ||
| }; |
| const t = langContent[lang] || langContent['fr']; | ||
| const titleEl = document.getElementById('youtube-section-title'); | ||
| const btnEl = document.getElementById('youtube-btn-text'); | ||
| if (titleEl) titleEl.textContent = t.youtube_title; | ||
| if (btnEl) btnEl.textContent = t.youtube_button; |
|
@copilot fais les dernières modifications |
There was a problem hiding this comment.
Pull request overview
Adds language-aware text for the YouTube section on music.html by targeting the “view all videos” label (and also the section heading) and updating the automation workflow to keep the button text targetable.
Changes:
- Wraps the YouTube section heading and “view all videos” text in
<span>s with IDs inmusic.html. - Adds a small per-language translation map and updates
switchLanguage()to update those YouTube texts. - Updates the YouTube auto-injection workflow to wrap the channel link text in a
<span id="youtube-btn-text">…</span>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
music.html |
Adds span targets + per-language translations and updates the language switcher to localize YouTube heading/button text. |
.github/workflows/youtube-section-update.yml |
Adjusts generated channel link HTML so the button label can be updated by the page’s language switcher. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DavidKRK/DavidKRK.github.io/sessions/b51d1e6d-60fe-4182-8214-12306892cf61 Co-authored-by: DavidKRK <136035295+DavidKRK@users.noreply.github.com>
Fait en commit
|
Agent-Logs-Url: https://github.com/DavidKRK/DavidKRK.github.io/sessions/dcf70b48-1135-44bd-ac4e-03d97467e100
name: Pull Request
about: Proposer un changement au projet
title: ''
labels: ''
assignees: ''
1. Quels sont les changements ?
Résumé des changements :
(Décrivez brièvement les modifications apportées.)
Tickets / Issues liés :
2. Pourquoi ces changements ?
Contexte métier :
(Expliquez la raison fonctionnelle ou business de ces changements.)
Justification technique :
(Expliquez les choix d'architecture ou d'implémentation retenus.)
3. Tests
Tests unitaires :
npm test/bundle exec rspec/ …)Tests manuels :
Performances & Sécurité :
4. Changements majeurs (Breaking Changes)
Cette PR introduit-elle des ruptures d'API ou de comportement ?
(Décrivez les ruptures et les impacts pour les consommateurs de l'API / les autres équipes.)
Instructions de migration :
(Si applicable, décrivez les étapes nécessaires pour migrer.)
5. Exigences de déploiement
Variables d'environnement :
NOM_VARvaleurNotes de déploiement supplémentaires :
(Toute information utile pour l'équipe de déploiement.)