Add localized directories to support Chinese

This commit is contained in:
yolain
2025-02-05 17:54:42 +08:00
parent 68c96e0a2e
commit 7866b053a3
6 changed files with 5063 additions and 2 deletions
+4 -1
View File
@@ -15,4 +15,7 @@ docs/**
.idea/
mmb-preset.custom.txt
config.yaml
node.tar.gz
node.tar.gz
.cursorrules
tools/ComfyUI-Easy-Use.json
+26
View File
@@ -0,0 +1,26 @@
{
"nodeCategories": {
"Util": "工具",
"Seed": "随机种",
"Prompt": "提示词",
"Loaders": "模型加载器",
"Adapter": "模型适配器",
"Inpaint": "内补重绘",
"PreSampling": "预采样参数",
"Sampler": "采样器",
"Fix": "修复相关",
"Pipe": "节点束",
"XY Inputs": "XY图表输入项",
"Image": "图像",
"Segmentation": "分割",
"Logic": "逻辑",
"\uD83D\uDEAB Deprecated": "\uD83D\uDEAB 已弃用",
"Type": "类型",
"Math": "数学计算",
"Switch": "开关",
"Index Switch": "索引开关",
"While Loop": "While循环",
"For Loop": "For循环",
"LoadImage": "加载图像"
}
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -37,7 +37,7 @@ class fullLoader:
"lora_model_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"lora_clip_strength": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"resolution": (resolution_strings,),
"resolution": (resolution_strings, {"default": "512 x 512"}),
"empty_latent_width": ("INT", {"default": 512, "min": 64, "max": MAX_RESOLUTION, "step": 8}),
"empty_latent_height": ("INT", {"default": 512, "min": 64, "max": MAX_RESOLUTION, "step": 8}),
+50
View File
@@ -0,0 +1,50 @@
# 自定义提示词自动补全工具
import os, sys
import glob
import shutil
output_file = None
cwd_path = os.path.dirname(os.path.realpath(__file__))
pyssss_path = os.path.join(cwd_path, "..", "ComfyUI-Custom-Scripts", "user")
combine_folder = os.path.join(cwd_path, "autocomplete")
def backup_autocomplete():
bak_file = os.path.join(pyssss_path, "autocomplete.txt.bak")
if os.path.exists(bak_file):
pass
elif os.path.exists(output_file):
shutil.copy(output_file, bak_file)
def combine_autocomplete():
if os.path.exists(combine_folder):
pass
else:
os.mkdir(combine_folder)
if os.path.exists(pyssss_path):
output_file = os.path.join(pyssss_path, "autocomplete.txt")
# 遍历 combine 目录下的所有 txt 文件,读取内容并合并
merged_content = ''
for file_path in glob.glob(os.path.join(combine_folder, '*.txt')):
with open(file_path, 'r', encoding='utf-8', errors='ignore') as file:
try:
file_content = file.read()
merged_content += file_content + '\n'
except UnicodeDecodeError:
pass
if merged_content != '':
# 将合并的内容写入目标文件 autocomplete.txt,并指定编码为 utf-8
with open(output_file, 'w', encoding='utf-8') as target_file:
target_file.write(merged_content)
if __name__ == "__main__":
arg = sys.argv[0]
if 'combine_autocomplete' in arg:
arg = sys.argv[1]
if arg == 'backup':
backup_autocomplete()
elif arg == 'combine':
combine_autocomplete()
else:
print("Usage: python combine_autocomplete.py [backup|combine]")
sys.exit(1)
+45
View File
@@ -0,0 +1,45 @@
# 开发人员使用(请勿运行)
# 将 https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation 的翻译文件转换格式以适配 ComfyUI核心 locales
import json
import os
import pathlib
old_json_path = 'ComfyUI-Easy-Use.json'
root_path = pathlib.Path(__file__).parent.parent
new_json_path = os.path.join(root_path,'locales/zh/nodeDefs.json')
def transform_dict(data):
new_dict = {}
for k, v in data.items():
new_dict[k] = {
"display_name": "",
"inputs": {}
}
if isinstance(v, dict):
for key, value in v.items():
if key == 'title':
new_dict[k]['display_name'] = value
elif key in ['inputs','widgets']:
for _key, _value in value.items():
new_dict[k]['inputs'] = {
**new_dict[k]['inputs'],
_key: {"name": _value}
}
return new_dict
def main():
# 读取原始JSON文件
with open(old_json_path, 'r', encoding='utf-8') as f:
data = json.load(f)
# 转换数据
transformed_data = transform_dict(data)
# 写入新的JSON文件
with open(new_json_path, 'w', encoding='utf-8') as f:
json.dump(transformed_data, f, ensure_ascii=False, indent=2)
if __name__ == '__main__':
main()