Localization and logging fix (#1038)

* Fix logging issue when text's length is 0 && Modify console context

* Modify zh-CN localization

* add file .gitattributes
This commit is contained in:
incredibleIdea 2025-07-03 11:05:39 +08:00 committed by GitHub
parent cfe6ada74c
commit 84a1fc13d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 54 additions and 3 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
text=auto eol=lf

View File

@ -297,5 +297,55 @@
"DPAD_UP": "十字键向上",
"DPAD_DOWN": "十字键向下",
"DPAD_LEFT": "十字键向左",
"DPAD_RIGHT": "十字键向右"
"DPAD_RIGHT": "十字键向右",
"BUTTON_1": "按钮1",
"BUTTON_2": "按钮2",
"up arrow": "方向上",
"down arrow": "方向下",
"left arrow": "方向左",
"right arrow": "方向右",
"Start Screen Recording": "开始屏幕录制",
"Stop Screen Recording": "停止屏幕录制",
"Context Menu": "菜单",
"Exit Emulation": "退出模拟器",
"System Save interval": "系统保存间隔",
"Are you sure you want to exit?": "您确定要退出吗?",
"Exit": "退出",
"Cancel": "取消",
"Note that some cheats require a restart to disable": "请注意,某些作弊码需要重新启动才能禁用",
"Drop save state here to load": "将状态保存文件拖放到此处以加载",
"Disks": "Disks",
"SWAP DISKS": "SWAP DISKS",
"EJECT/INSERT DISK": "EJECT/INSERT DISK",
"LEFT_TOP_SHOULDER": "LEFT_TOP_SHOULDER",
"RIGHT_TOP_SHOULDER": "RIGHT_TOP_SHOULDER",
"Requires restart": "Requires restart",
"Core (Requires restart)": "Core (Requires restart)",
"CRT beam": "CRT beam",
"CRT caligari": "CRT caligari",
"CRT lottes": "CRT lottes",
"CRT yeetron": "CRT yeetron",
"CRT zfast": "CRT zfast",
"SABR": "SABR",
"Bicubic": "Bicubic",
"Mix frames": "Mix frames",
"WebGL2": "WebGL2",
"VSync": "VSync",
"Video Rotation": "Video Rotation",
"Screenshot Source": "Screenshot Source",
"Screenshot Format": "Screenshot Format",
"Screenshot Upscale": "Screenshot Upscale",
"Screen Recording FPS": "Screen Recording FPS",
"Screen Recording Format": "Screen Recording Format",
"Screen Recording Upscale": "Screen Recording Upscale",
"Screen Recording Video Bitrate": "Screen Recording Video Bitrate",
"Screen Recording Audio Bitrate": "Screen Recording Audio Bitrate",
"Rewind Enabled (Requires restart)": "Rewind Enabled (Requires restart)",
"Menubar Mouse Trigger": "Menubar Mouse Trigger",
"Downward Movement": "Downward Movement",
"Movement Anywhere": "Movement Anywhere",
"Direct Keyboard Input": "Direct Keyboard Input",
"Forward Alt key": "Forward Alt key",
"Lock Mouse": "Lock Mouse"
}

View File

@ -479,14 +479,14 @@ class EmulatorJS {
this.elements.parent.appendChild(this.textElem);
}
localization(text, log) {
if (typeof text === "undefined") return;
if (typeof text === "undefined" || text.length === 0) return;
text = text.toString();
if (text.includes("EmulatorJS v")) return text;
if (this.config.langJson) {
if (typeof log === "undefined") log = true;
if (!this.config.langJson[text] && log) {
if (!this.missingLang.includes(text)) this.missingLang.push(text);
console.log("Translation not found for '" + text + "'. Language set to '" + this.config.language + "'");
console.log(`Translation not found for '${text}'. Language set to '${this.config.language}'`);
}
return this.config.langJson[text] || text;
}