MOKSHA · Weird Codes
समस्या | The Problem
हिंदी: English toggle करने के बाद भी स्क्रीन के नीचे हिंदी बची रहती थी: footer का उच्च मोड badge और mute बटन का tooltip पृष्ठभूमि ध्वनि म्यूट/अनम्यूट करें। भाषा बदलने वाला कोड सिर्फ़ दिखने वाला text बदलता था, title attributes और runtime पर बनने वाली strings नहीं।
English: After switching to English, some Hindi stayed on screen: the उच्च मोड badge in the footer and the mute button tooltip. The language switcher only updated visible text, not title attributes or strings built at runtime.
क्या ठीक हुआ | What Was Fixed
- Mode badge (उच्च / निम्न मोड) हिंदी: यह text audio.js में सीधे हार्डकोड था। अब यह t() से आता है। साथ ही एक _renderModeBadge() बनाया, जो भाषा बदलते ही badge को दोबारा लिखता है। इसलिए badge कभी पुरानी भाषा में नहीं अटकता। लोडिंग के दौरान का “जाँच रहे हैं…” भी अब दोनों भाषाओं में है।
English: The text was hardcoded in audio.js. It now goes through t(), and a new _renderModeBadge() re-renders the badge on every language change, including the “Checking…” state shown while loading.
- badge.textContent = '🟢 उच्च मोड';
- badge.textContent = t('hud.modeHigh');
- Tooltips का i18n (applyTitles) हिंदी: index.html में कोई data-i18n* था ही नहीं, इसलिए title कभी बदलते ही नहीं थे। अब data-i18n-title="key" लगाने पर एक छोटा helper applyTitles() page load पर और हर भाषा-बदलाव पर tooltip अपडेट करता है। mute बटन, help बटन, volume slider और mode badge पर यह लागू है।
English: index.html had no data-i18n* hooks, so title attributes never changed. A small applyTitles() helper now updates every data-i18n-title element on load and on each language change. Applied to the mute button, help button, volume slider and mode badge.
-🔊
+🔊
/** [data-i18n-title] वाले सभी elements का tooltip वर्तमान भाषा में सेट करता है। */
export function applyTitles(root = document) {
root.querySelectorAll('[data-i18n-title]').forEach((el) => {
const text = t(el.dataset.i18nTitle);
el.title = text;
if (el.tagName === 'BUTTON') el.setAttribute('aria-label', text);
});
}
- भाषा toggle का tooltip | Language toggle tooltip हिंदी: toggle पर सिर्फ़ aria-label था, title नहीं, इसलिए hover पर कुछ नहीं दिखता था। अब बाहर वाले पर data-i18n-title है। साथ ही English block में start.switchLabel हिंदी में लिखा मिला, उसे भी ठीक किया।
English: The toggle only had an aria-label, which doesn’t produce a hover tooltip. The wrapping now carries data-i18n-title. Also fixed start.switchLabel, which was written in Hindi inside the English block.
- HUD बटनों पर hover हिंदी: mute बटन के सिर्फ़ किनारे पर tooltip आता था, बीच में नहीं। इसे ठीक कर दिया गया।
English: The mute button’s tooltip only appeared on the icon’s edge, not its center. Fixed.
Files Changed
File बदलाव / Change
src/i18n.js नई hud.* keys (hi + en), applyTitles() helper, start.switchLabel का English fix
src/audio.js mode badge t() से, नया _renderModeBadge(), constructor में onLangChange
src/main.js applyTitles() load पर और onLangChange में
index.html footer/HUD बटनों, volume slider और भाषा toggle पर data-i18n-title
आगे क्या | What’s Next
हिंदी: ऊपर की पट्टी के 17 stat badges (पुण्य, पाप, प्रारब्ध आदि) के title अभी हिंदी में हैं। इन्हें भी इसी pattern से ठीक किया जाएगा। साथ ही English में पूरे game का एक बार पूरा पास होगा।
English: The 17 stat badges in the top bar (Punya, Paap, Praarabdha, etc.) still carry Hindi title attributes. They’ll get the same treatment, followed by a full English-mode pass through the whole game.
🎮 Play: https://weirdcodes.itch.io/moksha 💻 GitHub: https://github.com/weirdcodesofficial/MOKSHA 🐘 Mastodon: [लिंक यहाँ] 🐦 X: [लिंक यहाँ]
Human-designed, AI-assisted. सभी शास्त्रीय और रचनात्मक निर्णय Weired Codes द्वारा।

Top comments (0)