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!
===== 放在最上層(和其他 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>
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)