feat(game): HireRPG 中英双语 i18n(同一链接 / 自动识别 / 手动切换) - #33
Merged
Conversation
game.html 整体 i18n 化,复用主站 githire-lang localStorage 键: - 语言识别 ?lang= → localStorage → navigator.language(zh→中文,否则英文) - 导航加 中/EN 切换按钮,切换即持久化并即时重渲染;head title/meta 按语言切换 - 数据结构拆「语言无关几何/样式」+「分语言文本表」:MONSTER/QUESTION/ REGION/BAND/IT/ITEM/CODEX_TX;inventory 只存 key,名称运行时 itemText() 解析 - buildLocalizedData() 组装 MONSTERS/QUESTIONS/REGIONS/REGION_BANDS; localizeWorld() 切换时原地重建交互物/建筑文本,保留进度(HP/已击败/宝箱/位置) - 全部 UI 字面量(约 120 条 + 22 题)改走 t() 字典并补齐英文翻译 - 浏览器实测:标题/HUD/战斗(含战斗中切换即时重渲)/答题/胜利(道具+复活记录 按 key 双语解析)/图鉴/gameover 全双语零报错 chore: 运营推广物料目录 growth_marketing/ 加入 .gitignore(本地工作区,不入库) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
做了什么
把站内小游戏
docs/game.html整体 i18n 化,满足三点:同一链接、自动识别语言、可手动切换。复用主站githire-langlocalStorage 键,与 index/blog/skill 的语言选择互通。实现
?lang=→localStorage(githire-lang)→navigator.language(zh开头→中文,否则英文)。导航栏新增中 / EN切换按钮,切换即持久化并即时重渲染;<head>的 title / meta / og 按语言切换(zh 为 HTML 默认)。MONSTER_DEF+MONSTER_TX、QUESTION_TX、REGION/BAND_TX、IT_TX、ITEM_TX、CODEX_TX)。inventory只存{key,count,equipped},名称由itemText(key)运行时解析,避免语言切换后残留旧语言。buildLocalizedData()组装MONSTERS/QUESTIONS/REGIONS/REGION_BANDS;localizeWorld()在切换时原地重建WORLD.interactables/buildings文本,保留 HP / 已击败怪物 / 宝箱开启状态 / 玩家位置。t(key, params)字典并补齐英文翻译。growth_marketing/(本地工作区)加入.gitignore。测试
浏览器(gstack browse + 本地 http server)实测,零 console 报错:
localStorage+<html lang>),刷新后保持;?lang=en直达英文。范围
.claude/、.github/skills/),与本功能无关。🤖 Generated with Claude Code