fix: 使用 app.ui.settings API 获取 ComfyUI 语言设置

This commit is contained in:
InpaintRegionEditor Dev
2026-03-03 20:16:04 +08:00
parent 65722f376a
commit aedae4a941
+8 -3
View File
@@ -13,9 +13,14 @@ const i18n = {
data: null,
loaded: false,
// 获取当前语言
// 获取当前语言(使用 ComfyUI API)
getLocale() {
return localStorage['AGL.Locale'] || localStorage['Comfy.Settings.AGL.Locale'] || 'en-US';
try {
const locale = app.ui?.settings?.getSettingValue?.('Comfy.Locale');
if (locale) return locale;
} catch (e) {}
// 回退到浏览器语言
return navigator.language || 'en';
},
// 加载语言文件
@@ -53,7 +58,7 @@ const i18n = {
}
};
// 快捷函数(延迟获取,确保已加载)
// 快捷函数
function t(key) {
return i18n.t(key);
}