Skip to content

Add multilingual VTT transcript support with auto-detection#17

Draft
Copilot wants to merge 6 commits into
davelab6-all-langsfrom
copilot/add-multi-language-vtt-support
Draft

Add multilingual VTT transcript support with auto-detection#17
Copilot wants to merge 6 commits into
davelab6-all-langsfrom
copilot/add-multi-language-vtt-support

Conversation

Copilot AI commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

Enables displaying transcripts in 150+ languages when multiple localized VTT files exist. Video Ja9dTjY3uWU has 63 translations demonstrating the feature.

Core Changes

_plugins/with_vtt.rb - Auto-detects and loads all language variants

  • Scans for <video_id>.<lang>.vtt pattern (e.g., Ja9dTjY3uWU.en.vtt, Ja9dTjY3uWU.fr.vtt)
  • Exposes languages array with {code, name, cues} objects to templates
  • Sorts English first, then alphabetically by language name
  • Backward compatible: single-VTT videos work unchanged

_layouts/post.html - Language selector UI

  • Conditional dropdown (hidden for single-language videos)
  • Instant switching via JS DOM manipulation
  • localStorage persistence for user preference

assets/js/search.js - Language-aware search

  • Scoped to visible language transcript only

assets/css/style.css - Responsive selector styling

Usage

File naming convention:

_includes/captions/
  Ja9dTjY3uWU.en.vtt       # English
  Ja9dTjY3uWU.fr.vtt       # French
  Ja9dTjY3uWU.de.vtt       # German
  Ja9dTjY3uWU.zh-Hans.vtt  # Chinese (Simplified)

Posts reference base path (actual file need not exist):

caption_file: captions/Ja9dTjY3uWU.vtt

Plugin finds all variants automatically. No post modifications required.

Language Detection

# Plugin extracts video ID and finds all matches
Dir.glob("#{includes_dir}/captions/#{video_id}*.vtt")
  .map { |file| parse_language_code(file) }
  .sort_by { |lang| lang['code'] == 'en' ? '0' : "1#{lang['name']}" }

Liquid context variables:

  • languages - Array of all available languages
  • default_language - Preferred language code (defaults to 'en')
  • cues - Default language cues (backward compatible)

Files Modified

  • _plugins/with_vtt.rb (+256/-51)
  • _layouts/post.html (+81/-11)
  • assets/css/style.css (+50)
  • assets/js/search.js (+16/-10)
  • Test post and documentation (+606)

Total: 688 insertions, 26 deletions across 7 files

Original prompt

Using video ID Ja9dTjY3uWU as an example, update the site (starting with /_plugins/with_vtt.rb) so that it supports a full set of translated/localized VTT files for every post.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits October 26, 2025 23:07
Co-authored-by: davelab6 <261579+davelab6@users.noreply.github.com>
Co-authored-by: davelab6 <261579+davelab6@users.noreply.github.com>
Co-authored-by: davelab6 <261579+davelab6@users.noreply.github.com>
Co-authored-by: davelab6 <261579+davelab6@users.noreply.github.com>
Co-authored-by: davelab6 <261579+davelab6@users.noreply.github.com>
Copilot AI changed the title [WIP] Update site to support translated VTT files for posts Add multilingual VTT transcript support with auto-detection Oct 26, 2025
Copilot AI requested a review from davelab6 October 26, 2025 23:18
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