fix(i18n): keep lang/labels/dict function-scoped to fix Anki redeclaration crash#18
Merged
Merged
Conversation
…aration crash Anki reuses the same WebView JS context for both card faces, so module-level `const` declarations in the front template throw "Identifier already declared" when the back template script runs, breaking all rendering. Revert to declaring lang/labels/dict inside applyFenToBoard() (function scope, safe to re-evaluate). The coords button label is now set from step 7 of that same function, so no second lang lookup is needed and initCoordsToggle() stays free of any i18n dependency. https://claude.ai/code/session_01W4q82SG7ivHr15HiowDczK
…n; pin coords button top-right Language detection: prefer navigator.languages[0] (ordered preference array, more reliable in Chromium/Qt WebEngine WebViews used by Anki) over navigator.language, keeping the existing fallback chain for older runtimes. Layout: #coords-toggle is now position:fixed top:8px right:8px z-index:100, so it is pinned to the viewport corner and removed from the normal flow. The puzzle-meta and puzzle-actions flex containers reflow without the button, keeping all other elements centered. https://claude.ai/code/session_01W4q82SG7ivHr15HiowDczK
"Coords" → "Coord." for French so the translated value visibly differs from the hardcoded HTML default, making it possible to confirm the i18n code path is actually executing on the card. https://claude.ai/code/session_01W4q82SG7ivHr15HiowDczK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problème
Le PR #17 a cassé tout l'affichage en déplaçant
lang,labelsetdictau niveau module (consthors de toute fonction).Anki réutilise le même contexte JavaScript pour les deux faces d'une carte. Quand le script du template back s'exécute après celui du front, les déclarations
const lang,const labels,const dictau niveau module déclenchent :Ce crash interrompt tout le script — le plateau d'échecs ne se rend plus, aucune traduction n'est appliquée.
Fix
lang,labels,dictà l'intérieur deapplyFenToBoard()(portée fonction → ré-évaluable sans conflit).initCoordsToggle().Test plan
https://claude.ai/code/session_01W4q82SG7ivHr15HiowDczK
Generated by Claude Code