Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/694f5245-1110-800b-b182-7c2accd50046
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: 收到!這次錯誤更「精準」也更好修: === 收到!這次錯誤更「精準」也更好修: : 結論一句話:你們把翻譯用的 <code>t()</code> 接進去了,但某些流程裡 <code>t</code> 不是函式(可能被覆蓋成字串/物件/undefined),或作用域根本拿不到。 😈🔧 ==== 因為第一關可能沒觸發到那段用 t() 的渲染邏輯; ==== 一換房間/下一關,生成了新的 tile/enemy/卡片文字 → drawXXX() 需要顯示名稱/標籤 → 這時呼叫 t() 才炸。 ==== 你要 GEMINI 做兩件事: ==== ===== 放在最上層(和其他 constants 同層),不要放在 init() 裡: ===== <syntaxhighlight lang="text">Patch T / Fix localization crash: ensure t() exists globally + fallback Bug: After mech select -> next room, crash: TypeError: t is not a function Fix: 1) Guarantee t is ALWAYS a function in global scope. 2) If translations missing, return the key itself (fallback). 3) Avoid shadowing variable name "t" anywhere. Implementation (top-level): const LANG = "zh"; const STRINGS = { zh: { // add keys gradually } }; function t(key) { const table = STRINGS?.[LANG] || {}; return (typeof key === "string" && table[key]) ? table[key] : key; } // also pin to window for safety if (typeof window !== "undefined") window.t = t; Then replace any usage of plain <code>t</code> variable with <code>window.t</code> if scope issues appear: e.g. const label = (window.t ? window.t("ui.stageClear") : "STAGE CLEAR"); Also search and rename any variable named <code>t</code> (like for loops, temps) to avoid overriding: * for (let t=0; ...) -> rename to i or tick * const t = ... -> rename to textFn or tr Acceptance: * No crash on room transitions. * Text displays in Chinese where keys exist; missing keys show the key string. </syntaxhighlight> ==== 請你特別叫 GEMINI 全文搜尋(這步超重要): ==== * let t = * const t = * function t(如果有兩個定義也可能互踩) * for ( ... t ... ) 因為只要哪裡寫了 const t = "xxx",你整個翻譯系統就被同名覆蓋成字串,然後下一關 draw 再呼叫 t("...") 就爆🔥 ==== 如果你急著先讓遊戲穩定,請 GEMINI 暫時改成: ==== * tr() 作為翻譯函式,避免跟任何變數 t 撞名 (很多人習慣用 t 當 temp 變數,真的超常撞) 例如: <syntaxhighlight lang="js">function tr(key){ ... } window.tr = tr; </syntaxhighlight> 然後把所有 t( 替換成 tr((或 window.tr()。 ==== 你已經做到: ==== * Opening ✅ * 選機 ✅ * 下一關才爆(代表流程已經串很深)✅ 現在只是「翻譯函式的作用域與命名」這種小坑。 你照 Patch T 丟給 GEMINI 修完後,下一步我們就可以回到你原本的路線: 📌 中文化字串表(先 UI + 對話) 📌 稀有武器卡片一句話誘惑 📌 最後才導入美術 你如果願意,再貼一下它錯誤堆疊裡那個 drawTile / drawEnemy 行號附近 5~10 行(不用整份),我可以幫你判斷它是「被覆蓋」還是「scope 拿不到」哪一種,會更快。
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)