Skip to content

adding help button; adding meta description translations#6

Merged
hellpanderrr merged 1 commit intomainfrom
feature/help-pages
Nov 5, 2025
Merged

adding help button; adding meta description translations#6
hellpanderrr merged 1 commit intomainfrom
feature/help-pages

Conversation

@hellpanderrr
Copy link
Copy Markdown
Owner

@hellpanderrr hellpanderrr commented Nov 5, 2025

Summary by CodeRabbit

  • New Features
    • Extended language support to include Russian, Belorussian, Ukrainian, Bulgarian, Icelandic, and Lithuanian
    • Help button is now visible and accessible to assist with language selection
    • Text-to-speech control interface redesigned with dedicated sections for speed and volume adjustments

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 5, 2025

Walkthrough

The changes enhance UI presentation and refactor metadata management across multiple layers. CSS adds styles for a help button, header constraints, and TTS options container. HTML restructures the TTS controls and updates supported languages in metadata. JavaScript extracts language-specific metadata logic into a reusable updateMeta function, coordinating imports and updates.

Changes

Cohort / File(s) Summary
CSS Styling
wiktionary_pron/css/style.css
Introduces styles for #help_button (black text, padding, absolute positioning, hidden by default); adds max-width constraint to #header > h1; creates flex-based #tts_options container with centered justification; minor formatting adjustments.
HTML Structure
wiktionary_pron/index.html
Updates meta description to include Russian, Belorussian, Ukrainian, Bulgarian, Icelandic, and Lithuanian as supported languages; reactivates and repositions Help button with margin; refactors TTS controls from inline block to structured #tts_options container with separate Speed and Volume divs.
JavaScript Metadata Refactoring
wiktionary_pron/scripts/dynamic_meta.js
Introduces translatedMeta map with language descriptions categorized by transcription types (phonemic, phonetic, or both); extracts metadata update logic into new exported updateMeta(selectedLanguage) function; encapsulates title, description, and sample text updates with conditional dialect styling; wraps invocation in try/catch guard.
JavaScript Import Update
wiktionary_pron/scripts/main.js
Changes from default import to named import { updateMeta } from dynamic_meta.js; replaces inline document.title and meta description updates with single updateMeta(selectedLanguage) call.

Sequence Diagram

sequenceDiagram
    participant User
    participant main.js as main.js<br/>(Language Selection)
    participant dynamic_meta.js as dynamic_meta.js<br/>(Metadata Manager)
    participant DOM

    User->>main.js: Select Language
    main.js->>dynamic_meta.js: updateMeta(selectedLanguage)
    dynamic_meta.js->>dynamic_meta.js: Look up translatedMeta<br/>Build description string<br/>Apply dialect styling
    dynamic_meta.js->>DOM: Update document.title
    dynamic_meta.js->>DOM: Update meta description
    dynamic_meta.js->>DOM: Update sample text
    DOM-->>User: Display Updated Metadata
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas requiring extra attention:
    • Verify translatedMeta map in dynamic_meta.js covers all languages referenced in HTML meta description
    • Confirm TTS options container layout changes in CSS and HTML align visually (flex layout, spacing, positioning)
    • Validate the try/catch guard in dynamic_meta.js handles edge cases (missing URL params, invalid language codes)
    • Test that #help_button visibility toggle works correctly with the new CSS display: none default

Poem

🐰 A button hops into view, styles align,
Metadata flows through functions so fine,
TTS options dance in containers with grace,
Languages bloom across every space—
One refactor binds them all in place! ✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the two main changes: reactivating a help button and adding translated metadata descriptions for multiple languages.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/help-pages

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
wiktionary_pron/css/style.css (1)

469-469: Remove duplicate --volume-icon declaration.

The --volume-icon CSS variable is already declared at line 469 with the identical value. This duplicate declaration is unnecessary and should be removed to avoid confusion.

Apply this diff:

     --icon-spinner: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='currentColor' d='M304 48c0-26.5-21.5-48-48-48s-48 21.5-48 48s21.5 48 48 48s48-21.5 48-48zm0 416c0-26.5-21.5-48-48-48s-48 21.5-48 48s21.5 48 48 48s48-21.5 48-48zM48 304c26.5 0 48-21.5 48-48s-21.5-48-48-48s-48 21.5-48 48s21.5 48 48 48zm464-48c0-26.5-21.5-48-48-48s-48 21.5-48 48s21.5 48 48 48s48-21.5 48-48zM142.9 437A48 48 0 1 0 75 369.1a48 48 0 1 0 67.9 67.9zm0-294.2A48 48 0 1 0 75 75a48 48 0 1 0 67.9 67.9zM369.1 437A48 48 0 1 0 437 369.1a48 48 0 1 0-67.9 67.9z'/%3E%3C/svg%3E");
-    --volume-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20384%20512%22%3E%3C!--!Font%20Awesome%20Free%206.7.2%20by%20%40fontawesome%20-%20https%3A%2F%2Ffontawesome.com%20License%20-%20https%3A%2F%2Ffontawesome.com%2Flicense%2Ffree%20Copyright%202025%20Fonticons%2C%20Inc.--%3E%3Cpath%20d%3D%22M215%2072L126.1%20161H24c-13.3%200-24%2010.7-24%2024v144c0%2013.3%2010.7%2024%2024%2024h102.1l89%2089c15%2015%2041%204.5%2041-17V89c0-21.5-26-32-41-17zm123.2%20108.1c-11.6-6.3-26.2-2.2-32.6%209.5-6.4%2011.6-2.2%2026.2%209.5%2032.6C328%20229.3%20336%20242.6%20336%20257c0%2014.4-8%2027.7-20.9%2034.8-11.6%206.4-15.8%2021-9.5%2032.6%206.4%2011.7%2021.1%2015.8%2032.6%209.5%2028.2-15.6%2045.8-45%2045.8-76.9s-17.5-61.3-45.8-76.9z%22%2F%3E%3C%2Fsvg%3E");
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4a187f and 26edf21.

📒 Files selected for processing (4)
  • wiktionary_pron/css/style.css (5 hunks)
  • wiktionary_pron/index.html (3 hunks)
  • wiktionary_pron/scripts/dynamic_meta.js (2 hunks)
  • wiktionary_pron/scripts/main.js (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
wiktionary_pron/scripts/dynamic_meta.js (1)
wiktionary_pron/scripts/languages.js (2)
  • languages (1-98)
  • languages (1-98)
wiktionary_pron/scripts/main.js (1)
wiktionary_pron/scripts/dynamic_meta.js (1)
  • selectedLanguage (84-84)
🔇 Additional comments (11)
wiktionary_pron/css/style.css (3)

222-227: LGTM! Help button styles support dynamic visibility.

The display: none initial state is correctly toggled to inline-block by JavaScript in wiktionary_pron/scripts/main.js (lines 623-624) when a language is selected.


237-240: LGTM! Prevents header title overflow.

The max-width: 80% constraint prevents the header title from overlapping with the help button when it's displayed.


246-250: LGTM! Supports refactored TTS controls layout.

The flex container aligns with the restructured TTS options in wiktionary_pron/index.html (lines 98-103), which wraps Speed and Volume inputs in separate divs.

wiktionary_pron/index.html (3)

23-24: LGTM! Meta description updated with additional language support.

The meta description now accurately reflects the expanded language support including Russian, Belorussian, Ukrainian, Bulgarian, Icelandic, and Lithuanian. This aligns with the languages defined in wiktionary_pron/scripts/languages.js.


63-64: LGTM! Help button reactivated for language-specific help pages.

The button visibility is now controlled dynamically via JavaScript in wiktionary_pron/scripts/main.js (lines 619-633), which sets the display style and onclick handler based on the selected language.


98-103: LGTM! TTS controls refactored into structured container.

The TTS controls are now properly organized within a #tts_options div, which uses the flex layout defined in wiktionary_pron/css/style.css (lines 246-250) for centered alignment.

wiktionary_pron/scripts/main.js (2)

1-1: LGTM! Import updated to match new export pattern.

The named import { updateMeta } correctly matches the export in wiktionary_pron/scripts/dynamic_meta.js (line 89). This change supports the refactoring that centralizes metadata management.


692-692: LGTM! Delegates metadata updates to centralized function.

Replacing inline document.title and meta description updates with updateMeta(selectedLanguage) improves maintainability by consolidating language-specific metadata logic in wiktionary_pron/scripts/dynamic_meta.js.

wiktionary_pron/scripts/dynamic_meta.js (3)

3-39: LGTM! Comprehensive translations for meta descriptions.

The translatedMeta map provides native-language descriptions organized by transcription type (phonemic, phonetic, or both). This enhances SEO and user experience for non-English speakers.


82-88: LGTM! Proper error handling for initialization.

The try/catch block appropriately handles potential errors during URL parameter parsing and initial metadata updates.


89-89: LGTM! Exports updateMeta for use by main.js.

The named export correctly provides the updateMeta function to wiktionary_pron/scripts/main.js (line 1), establishing a clean public API for metadata management.

Comment on lines +63 to +80
function updateMeta(selectedLanguage) {
if (selectedLanguage) {
document.title = `Online ${selectedLanguage} IPA transcription`;
const lang = languages[selectedLanguage];
if (lang) {
const availableStyles = lang.styles.join(", ");
let availableStyles = " Dialects: " + lang.styles.join(", ").trim() + ".";
if (lang.styles[0] === "Default") {
availableStyles = "";
}
const availableForms = lang.forms
.map((form) => form.toLowerCase())
.join("/");
document.head.children.description.content = `Online ${selectedLanguage} to IPA ${availableForms} transcription generator. Dialects: ${availableStyles}`;
document.head.children.description.content = `Online ${selectedLanguage} to IPA ${availableForms} transcription generator.${availableStyles} ${translatedMeta[selectedLanguage]}`;
}
document.querySelector("#text_to_transcribe").value =
sampleTexts[selectedLanguage];
console.log("sample text", sampleTexts[selectedLanguage]);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix meta element access method.

Line 75 uses document.head.children.description.content, which is incorrect. The children property is an HTMLCollection indexed numerically, not by element name. This will fail at runtime.

Apply this diff to fix the meta element access:

 function updateMeta(selectedLanguage) {
   if (selectedLanguage) {
     document.title = `Online ${selectedLanguage} IPA transcription`;
     const lang = languages[selectedLanguage];
     if (lang) {
       let availableStyles = " Dialects: " + lang.styles.join(", ").trim() + ".";
       if (lang.styles[0] === "Default") {
         availableStyles = "";
       }
       const availableForms = lang.forms
         .map((form) => form.toLowerCase())
         .join("/");
-      document.head.children.description.content = `Online ${selectedLanguage} to IPA ${availableForms} transcription generator.${availableStyles} ${translatedMeta[selectedLanguage]}`;
+      const metaDescription = document.querySelector('meta[name="description"]');
+      if (metaDescription) {
+        metaDescription.content = `Online ${selectedLanguage} to IPA ${availableForms} transcription generator.${availableStyles} ${translatedMeta[selectedLanguage]}`;
+      }
     }
     document.querySelector("#text_to_transcribe").value =
       sampleTexts[selectedLanguage];
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function updateMeta(selectedLanguage) {
if (selectedLanguage) {
document.title = `Online ${selectedLanguage} IPA transcription`;
const lang = languages[selectedLanguage];
if (lang) {
const availableStyles = lang.styles.join(", ");
let availableStyles = " Dialects: " + lang.styles.join(", ").trim() + ".";
if (lang.styles[0] === "Default") {
availableStyles = "";
}
const availableForms = lang.forms
.map((form) => form.toLowerCase())
.join("/");
document.head.children.description.content = `Online ${selectedLanguage} to IPA ${availableForms} transcription generator. Dialects: ${availableStyles}`;
document.head.children.description.content = `Online ${selectedLanguage} to IPA ${availableForms} transcription generator.${availableStyles} ${translatedMeta[selectedLanguage]}`;
}
document.querySelector("#text_to_transcribe").value =
sampleTexts[selectedLanguage];
console.log("sample text", sampleTexts[selectedLanguage]);
}
}
function updateMeta(selectedLanguage) {
if (selectedLanguage) {
document.title = `Online ${selectedLanguage} IPA transcription`;
const lang = languages[selectedLanguage];
if (lang) {
let availableStyles = " Dialects: " + lang.styles.join(", ").trim() + ".";
if (lang.styles[0] === "Default") {
availableStyles = "";
}
const availableForms = lang.forms
.map((form) => form.toLowerCase())
.join("/");
const metaDescription = document.querySelector('meta[name="description"]');
if (metaDescription) {
metaDescription.content = `Online ${selectedLanguage} to IPA ${availableForms} transcription generator.${availableStyles} ${translatedMeta[selectedLanguage]}`;
}
}
document.querySelector("#text_to_transcribe").value =
sampleTexts[selectedLanguage];
}
}
🤖 Prompt for AI Agents
In wiktionary_pron/scripts/dynamic_meta.js around lines 63 to 80, the code uses
document.head.children.description.content which is invalid because children is
numerically indexed; replace this with a proper meta lookup and assignment:
query for the description meta (e.g.,
document.querySelector('meta[name="description"]')), check it isn’t null, and
set its content to the generated string; if the meta doesn’t exist, create a
meta element with name="description", set its content, and append it to
document.head.

@hellpanderrr hellpanderrr merged commit 6d5c716 into main Nov 5, 2025
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.

1 participant