Skip to content

fix(site): scope language picker to lesson pages - #412

Open
Deadeye102000 wants to merge 1 commit into
rohitg00:mainfrom
Deadeye102000:fix-404-lang-switcher-landing
Open

fix(site): scope language picker to lesson pages#412
Deadeye102000 wants to merge 1 commit into
rohitg00:mainfrom
Deadeye102000:fix-404-lang-switcher-landing

Conversation

@Deadeye102000

Copy link
Copy Markdown

What this PR does

Scopes the language picker to lesson pages only, since window.AIFS_onLangChange — the hook that actually re-renders content in the selected language — is only ever defined on lesson.html.

Kind of change

  • Docs / website / tooling

Checklist

  • Code runs without errors with the listed dependencies
  • No comments in code files (docs explain, code is self-explanatory)
  • Tested locally / code output matches what docs/en.md claims

Phase / lesson

N/A — this is a site-level fix (site/lang-picker.js), not a lesson change.

Notes for reviewer

Root cause: the picker mounted on index.html too, but the landing page has no AIFS_onLangChange hook, so selecting a language updated localStorage/the URL but never re-rendered content — matching the reported bug. docs/i18n.md's "Site switcher" row documents lesson.html as the only intended location, so I gated init() on window.AIFS_onLangChange being defined rather than trying to add landing-page translations that don't exist in the pipeline.

Tested locally on both pages: index.html no longer mounts the picker; lesson.html still mounts it and language switching still works (translated markdown still fetches, falls back to English correctly).

Left the empty <div id="langPicker"> in index.html in place rather than removing it — kept the diff to one file/one behavior per the contribution guidelines.

Fixes #404

The picker showed on index.html but window.AIFS_onLangChange is only
defined on lesson.html, so selecting a language there updated
localStorage/URL but never re-rendered content. docs/i18n.md
documents the site switcher as belonging to lesson.html only — gate
mount() accordingly.

Fixes rohitg00#404
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f87c1337-e791-4c02-8b17-3cbf86b87463

📥 Commits

Reviewing files that changed from the base of the PR and between 7c33235 and 46e512b.

📒 Files selected for processing (1)
  • site/lang-picker.js

📝 Walkthrough

Walkthrough

The language picker now requires both its host element and language-change callback before initialization. Certification lessons still force English and hide the picker. Other pages mount the picker after the guard.

Changes

Language picker initialization

Layer / File(s) Summary
Validate language picker prerequisites
site/lang-picker.js
init exits when the picker host or AIFS_onLangChange callback is missing. Certification pages hide the picker after validation. Other pages mount the picker directly.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 46e51

This narrowly scopes the language picker to lesson pages where language switching is supported; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: rohitg00

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR hides the landing-page picker instead of making landing-page content update as required by issue #404. Implement landing-page language rendering, or update issue #404 acceptance criteria to approve removing the picker.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: limiting the language picker to lesson pages.
Description check ✅ Passed The description directly explains the language-picker scope change, root cause, behavior, and testing.
Out of Scope Changes check ✅ Passed The changes are limited to the language-picker initialization logic and remain related to the reported landing-page bug.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Deadeye102000

Copy link
Copy Markdown
Author

Deliberate, not an oversight — this looks like one of the bot's heuristics comparing the diff against the issue's literal wording, without visibility into the i18n pipeline's actual scope.

There's no translated content source for the landing page anywhere in the repo (see docs/i18n.md — the "Site switcher" row scopes it to lesson.html only; landing-page strings were never part of the translation pipeline). So there was nothing for the picker to render into on index.html — it updated localStorage/URL but had no content to swap in, which is the bug.

Building a full landing-page i18n system would be a much larger scope change than this bug report calls for. Given the picker was never functional there and docs/i18n.md documents lesson.html as its intended home, removing it from a page where it can't work seemed like the right fix rather than expanding scope to make it work everywhere.

Happy to go the other direction if @rohitg00 would rather see landing-page translations added — just flagging that's a separate, bigger piece of work.

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.

[bug] Language switcher not working

1 participant